We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
0 parents commit a68892eCopy full SHA for a68892e
2 files changed
dephell_versioning/__init__.py
dephell_versioning/_cached_property.py
@@ -0,0 +1,18 @@
1
+
2
3
+# https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
4
+# https://github.com/pydanny/cached-property/blob/master/cached_property.py
5
+class cached_property(object): # noqa: N801
6
+ """
7
+ A property that is only computed once per instance and then replaces itself
8
+ with an ordinary attribute. Deleting the attribute resets the property.
9
10
+ def __init__(self, func):
11
+ self.__doc__ = func.__doc__
12
+ self.func = func
13
14
+ def __get__(self, obj, cls):
15
+ if obj is None:
16
+ return self
17
+ value = obj.__dict__[self.func.__name__] = self.func(obj)
18
+ return value
0 commit comments