base_multiton module¶
Implementation of the multiton design pattern.
- class gemseo.utils.base_multiton.BaseABCMultiton(name, bases, namespace, **kwargs)[source]¶
Bases:
ABCMeta
,BaseMultiton
A metaclass of abstract classes implementing the multiton design pattern.
- classmethod clear_cache()¶
Clear the cache.
- Return type:
None
- mro()¶
Return a type’s method resolution order.
- register(subclass)¶
Register a virtual subclass of an ABC.
Returns the subclass, to allow usage as a class decorator.
- class gemseo.utils.base_multiton.BaseMultiton(class_name, class_bases, class_dict)[source]¶
Bases:
GoogleDocstringInheritanceMeta
A metaclass implementing the multiton design pattern.
See Multiton.
As opposed to the
functools.lru_cache
, the objects built from this metaclass can be pickled.This metaclass has a cache which is a mapping of classes to class instances. When instantiating a class, if an instance has already been created for this class, then the cached instance is used, otherwise a new instance is created and stored into the cache.
- mro()¶
Return a type’s method resolution order.