Package paramz :: Module caching :: Class Cacher
[hide private]
[frames] | no frames]

Class Cacher

source code


Instance Methods [hide private]
 
__init__(self, operation, limit=3, ignore_args=(), force_kwargs=(), cacher_enabled=True)
Cache an `operation`.
source code
 
disable_cacher(self)
Disable the caching of this cacher.
source code
 
enable_cacher(self)
Enable the caching of this cacher.
source code
 
id(self, obj)
returns the self.id of an object, to be used in caching individual self.ids
source code
 
combine_inputs(self, args, kw, ignore_args)
Combines the args and kw in a unique way, such that ordering of kwargs does not lead to recompute
source code
 
prepare_cache_id(self, combined_args_kw)
get the cacheid (conc.
source code
 
ensure_cache_length(self)
Ensures the cache is within its limits and has one place free
source code
 
add_to_cache(self, cache_id, inputs, output)
This adds cache_id to the cache, with inputs and output
source code
 
__call__(self, *args, **kw)
A wrapper function for self.operation,
source code
 
on_cache_changed(self, direct, which=None)
A callback funtion, which sets local flags when the elements of some cached inputs change
source code
 
reset(self)
Totally reset the cache
source code
 
__deepcopy__(self, memo=None) source code
 
__getstate__(self, memo=None) source code
 
__setstate__(self, memo=None) source code
 
__str__(self, *args, **kwargs)
str(x)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]
  __name__

Inherited from object: __class__

Method Details [hide private]

__init__(self, operation, limit=3, ignore_args=(), force_kwargs=(), cacher_enabled=True)
(Constructor)

source code 

Cache an `operation`. If the operation is a bound method we will
create a cache (FunctionCache) on that object in order to keep track
of the caches on instances.

Warning: If the instance already had a Cacher for the operation
         that Cacher will be overwritten by this Cacher!

:param callable operation: function to cache
:param int limit: depth of cacher
:param [int] ignore_args: list of indices, pointing at arguments to ignore in `*args` of `operation(*args)`. This includes self, so make sure to ignore self, if it is not cachable and you do not want this to prevent caching!
:param [str] force_kwargs: list of kwarg names (strings). If a kwarg with that name is given, the cacher will force recompute and wont cache anything.
:param int verbose: verbosity level. 0: no print outs, 1: casual print outs, 2: debug level print outs

Overrides: object.__init__

disable_cacher(self)

source code 

Disable the caching of this cacher. This also removes previously cached results

prepare_cache_id(self, combined_args_kw)

source code 

get the cacheid (conc. string of argument self.ids in order)

on_cache_changed(self, direct, which=None)

source code 

A callback funtion, which sets local flags when the elements of some cached inputs change

this function gets 'hooked up' to the inputs when we cache them, and upon their elements being changed we update here.

__str__(self, *args, **kwargs)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

Property Details [hide private]

__name__

Get Method:
unreachable.__name__(self)