MCPcopy Create free account
hub / github.com/catboost/catboost / lazy

Function lazy

library/python/func/__init__.py:22–40  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

20
21
22def lazy(func):
23 result = _Result()
24
25 lock = threading.Lock()
26
27 @functools.wraps(func)
28 def wrapper(*args, **kwargs):
29 try:
30 return result.result
31 except AttributeError:
32 with lock:
33 try:
34 return result.result
35 except AttributeError:
36 result.result = func(*args, **kwargs)
37
38 return result.result
39
40 return wrapper
41
42
43def lazy_property(fn):

Callers

nothing calls this directly

Calls 2

_ResultClass · 0.85
LockMethod · 0.45

Tested by

no test coverage detected