# CacheKey class¶

(Shortest import: from brian2.utils.caching import CacheKey)

class brian2.utils.caching.CacheKey[source]

Bases: object

Mixin class for objects that will be used as keys for caching (e.g. Variable objects) and have to define a certain “identity” with respect to caching. This “identity” is different from standard Python hashing and equality checking: a Variable for example would be considered “identical” for caching purposes regardless which object (e.g. NeuronGroup) it belongs to (because this does not matter for parsing, creating abstract code, etc.) but this of course matters for the values it refers to and therefore for comparison of equality to other variables.

Classes that mix in the CacheKey class should re-define the _cache_irrelevant_attributes attribute to note all the attributes that should be ignored. The property _state_tuple will refer to a tuple of all attributes that were not excluded in such a way; this tuple will be used as the key for caching purposes.

Attributes

 _cache_irrelevant_attributes Set of attributes that should not be considered for caching of state update code, etc.

Details

_cache_irrelevant_attributes

Set of attributes that should not be considered for caching of state update code, etc.