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

Function lazy_property

library/python/func/__init__.py:43–58  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

41
42
43def lazy_property(fn):
44 attr_name = '_lazy_' + fn.__name__
45
46 lock = threading.Lock()
47
48 @property
49 def _lazy_property(self):
50 if hasattr(self, attr_name):
51 return getattr(self, attr_name)
52
53 with lock:
54 if not hasattr(self, attr_name):
55 setattr(self, attr_name, fn(self))
56 return getattr(self, attr_name)
57
58 return _lazy_property
59
60
61class classproperty(object):

Callers

nothing calls this directly

Calls 1

LockMethod · 0.45

Tested by

no test coverage detected