Commit 5a90bac2 authored by Denis Bilenko's avatar Denis Bilenko

add lazy_property class to gevent.util

parent 83f8c331
......@@ -42,3 +42,15 @@ class wrap_errors(object):
return getattr(self.func, item)
class lazy_property(object):
def __init__(self, calculate_function):
self._calculate = calculate_function
def __get__(self, obj, _=None):
if obj is None:
return self
value = self._calculate(obj)
setattr(obj, self._calculate.func_name, value)
return value
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment