__init__(self,
root,
info=( ) ,
fname=None,
modname=None,
mod=None)
(Constructor)
| source code
|
x.__init__(...) initializes x; see help(type(x)) for signature
- Parameters:
info (tuple(anything)) - This is where you specify the parameters from which the cached
value can be computed. It is essentially a look-up key for the
value.
fname (str) - You can specify that the cached value depends on the contents of
a file (in addition to other parameters). See fileinfo for details.
modname (str or tuple(str)) - You can specify that the value depends on a module (or a list of
modules). (You give the names of the modules here.) In which
case, it tries to detect changes to the specified modules. See
namedModInfo for details. You use this argument
to protect youself against changes to the code used to compute
the cached value. Obviously, you don't want to load a value from last weeks, buggy
implementation.
modname (str or tuple(str)) - You can specify that the value depends on a module (or a list of
modules). (You give the module itself here.) In which case, it
tries to detect changes to the specified modules. See modinfo for details.
mod (module or tuple (module ).)
- Overrides:
object.__init__
Notes:
-
Certain compromises were made in the handling of
modname and mod . Even if you use them,
you are not 100% guaranteed to be protected from all changes to the
code used to compute the cached values. To be entirely safe, you
should manually clear the cache when ever you change your code.
However, this will probably save your tail if you forget to clear
the cache. See modinfo for details.
-
If there is an error when reading files (i.e. if
fname , modname , or mod is
specified), then the object will be constructed with
info=None . This will lead to a OSError if you then call load on the object, which is what you'd get from a
cache miss. Calling dump or bg_dump will silently do nothing.
|