memo - Memoize objects according to a given key

Memoize class instances according to a given key.

By default the key only assumes the True value, thus implementing a singleton.

class Memo[source]

Base class for classes that require memoization.

Subclasses should override the _key(*args, **kwargs) method to compute a key on the constructor’s arguments.

Care should be taken to avoid calling __init__() again for entities already constructed.

static __new__(cls, *args, **kwargs)[source]

Return the instance corresponding to the given key, creating it if it doesn’t exist.