CachedClass

class CachedClass(*args, **kwargs)[source]

Bases: object

A class that caches its instances.

Any class that inherits from CachedClass will be instantiated once per parameter set. Any subsequent attempts to instantiate a CachedClass with the same parameters will return the same object. CachedClass is not thread-safe.

Examples

>>> x = CachedClass(1)
>>> y = CachedClass(1)
>>> z = CachedClass(2)
>>> x is y
True
>>> x is z
False
__init__()

Methods