Wrapping classes
Jeremy Sanders
jeremy+python at jeremysanders.net
Thu Sep 22 16:40:20 EDT 2005
Is it possible to implement some sort of "lazy" creation of objects only
when the object is used, but behaving in the same way as the object?
For instance:
class Foo:
def __init__(self, val):
"""This is really slow."""
self.num = val
# this doesn't call Foo.__init__ yet
a = lazyclass(Foo, 6)
# Foo is only initalised here
print a.num
What I really want to do is make an object which looks like a numarray,
but only computes its contents the first time it is used.
Thanks
Jeremy
More information about the Python-list
mailing list