Quantcast
Channel: How to create lazy initialization (proxy) wrapper in python? - Stack Overflow
Browsing all 2 articles
Browse latest View live

Answer by Alain T. for How to create lazy initialization (proxy) wrapper in...

You could write a general purpose decorator for this. Assuming you add a function called __lazyinit__ to your class, this decorator will ensure it is called before each of the decorated method that...

View Article



How to create lazy initialization (proxy) wrapper in python?

Given an expensive to initialize object and 2 consumers:class A: def __init__(): time.sleep(42) self.foo = 1def func1(obj: A): passdef func2(obj: A): print(A.foo)How to create a wrapper that would...

View Article
Browsing all 2 articles
Browse latest View live




Latest Images