Open
Description
I want to implement a new more unattended way to proxy objects, inheriting a LazyObject class instead of doing a = Proxy(lambda: A(5))
I'm doing this:
from lazy_object_proxy import Proxy
class LazyObject:
def __new__(cls, *args, **kwargs):
class_ = type(object.__class__.__name__, (cls,), {})
class_.__new__ = lambda cls_, *args_, **kwargs_: object.__new__(cls_)
return Proxy(lambda: class_(*args, **kwargs))
class A(LazyObject):
def __init__(self, x):
print("Init")
self.x = 5
a = A(5)
print('GO')
print(a.x)
result:
GO
Init
5
What do you think about this implementation? do you think I've missed any concern? any way to implement this in C?
Regards
Metadata
Metadata
Assignees
Labels
No labels