schrodinger ::
infra ::
util ::
CreateWhenNeeded ::
Class CreateWhenNeeded
|
|
Class CreateWhenNeeded
object --+
|
CreateWhenNeeded
This class can be used like property() (i.e., it is a descriptor; see
section 3.3.2.2 in the python reference). It will hold off on creating
the object until it is needed, but once it has been created it will
return the object directly.
It's best used for attributes that are expensive to calculate (as
measured by profiling, of course) and not always used.
|
__init__(self,
function,
name=None,
doc=None)
Create the descriptor. |
|
|
|
__get__(self,
obj,
cls)
Calculate the value from the function, then set the attribute of the
object to this result and return it. |
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
__init__(self,
function,
name=None,
doc=None)
(Constructor)
|
|
Create the descriptor.
- Overrides:
object.__init__
|