Python decorator for easy lazy loading class properties
pip install lazyprop
Decorate any class method to memoize / cache object properties.
from lazyprop import lazyprop
class Foo(object):
def __init__(self):
self.load_count = 0
@lazyprop
def lazy(self):
self.load_count += 1
>> f = Foo()
>> f.lazy
>> f.lazy # second access should use cached result
>> print(f.load_count)
1