Package tdi :: Module interfaces :: Class MemoizerInterface
[frames] | no frames]

Class MemoizerInterface

source code

object --+
         |
        MemoizerInterface

Interface for factory memoizers

Note: dicts implement this easily, but without the (optional) local lock.

Instance Methods
bool
__contains__(self, key)
Is this key memoized already?
source code
any
__getitem__(self, key)
Get memoized entry
source code
 
__setitem__(self, key, value)
Memoize entry
source code

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

Instance Variables
Lock lock
A lock object for the cache access.
Properties

Inherited from object: __class__

Method Details

__contains__(self, key)
(In operator)

source code 
Is this key memoized already?
Parameters:
  • key (hashable) - Key
Returns: bool
Is it?
Raises:
  • TypeError - Unhashable key

__getitem__(self, key)
(Indexing operator)

source code 
Get memoized entry
Parameters:
  • key (hashable) - Key
Returns: any
The memoized value
Raises:
  • TypeError - Unhashable key

__setitem__(self, key, value)
(Index assignment operator)

source code 
Memoize entry
Parameters:
  • key (hashable) - Key
  • value (any) - The value to memoize
Raises:
  • TypeError - Unhashable key

Instance Variable Details

lock

A lock object for the cache access. The lock needs an acquire method and a release method. If the attribute does not exist or is None, cache access is serialized using a global lock. If you have multiple caches (for whatever reasons) this local lock is handy.
Type:
Lock