The first example in the documentation first throws an AttributeError and when obj.foobar is changed to obj then it just throws an NameError.
Given the sparseness of documentation shouldn't the first (and only?) example work and demonstrate what the package is capable of?
I was thinking about something along the lines of:
import lazy_object_proxy
import time
def expensive_func():
print('starting calculation')
time.sleep(2) # just as example for a very slow computation
print('finished calculation')
# create expensive object
return 10
obj = lazy_object_proxy.Proxy(expensive_func)
# function is called only when object is actually used
print(obj) # now expensive_func is called
print(obj) # the expensive_func isn't called but the result is "remembered".
If you want I can put together a PR but I wasn't sure if it needs some discussion beforehand.
The first example in the documentation first throws an
AttributeError
and whenobj.foobar
is changed toobj
then it just throws anNameError
.Given the sparseness of documentation shouldn't the first (and only?) example work and demonstrate what the package is capable of?
I was thinking about something along the lines of:
If you want I can put together a PR but I wasn't sure if it needs some discussion beforehand.