arsenal.cache package¶
Submodules¶
arsenal.cache.lazy module¶
-
class
arsenal.cache.lazy.lazy(func)[source]¶ Bases:
objectLazily load a property defined by a method. The method wrapped is called at most once to retrieve the result and the result is reused. If the method is a generator, the value is stored as a list.
Note: instances must have a __dict__ attribute in order for this property to work, i.e. no ‘__slots__’ class attribute.
Implementation detail: this is not implemented as a data descriptor so that we can completely avoid the function call overhead. If one choses to invoke __get__ by hand the property will still work as expected because the lookup logic is replicated in __get__ for manual invocation.
arsenal.cache.memoize module¶
-
class
arsenal.cache.memoize.ShelfBasedCache(func, key, None_is_bad=False)[source]¶ Bases:
objectcache a function’s return value to avoid recalulation and save cache in a shelve.
-
class
arsenal.cache.memoize.memoize(func)[source]¶ Bases:
objectcache a function’s return value to avoid recalulation
-
class
arsenal.cache.memoize.memoize_persistent(func, filename=None)[source]¶ Bases:
objectcache a function’s return value to avoid recalulation and save the cache (via pickle) at system exit so that it persists.
- WARNING: retrieves cache for functions which might not be equivalent
- if a revision is made to the code which is used to compute it.
arsenal.cache.pkl module¶
Caching with pickle and the file system.