sharing persisten cache between modules
Fredrik Lundh
fredrik at pythonware.com
Mon Oct 23 13:03:01 EDT 2006
Bart Ogryczak wrote:
>> why not just put the cache management
>> code in a module that's imported by any submodule that wants to use it ?
>
> The problem is, that then it is not shared. If I do it like that, each
> module has it´s own copy of the cache.
nope. modules are shared, and all module-level objects are shared as
well. the code in a module is only executed when you import it the
first time; all further imports will get a reference to the same module
instance.
> Maybe I´m doing something wrong. I´ve made a cache module, imported it in
> each of the submodules.
that should work. how do you create the cache in the module, and how do
the individual modules access the cache?
</F>
More information about the Python-list
mailing list