gemseo.utils.base_multiton module#
Implementation of the multiton design pattern.
- class BaseABCMultiton(name, bases, namespace, /, **kwargs)[source]#
Bases:
ABCMeta
,BaseMultiton
A metaclass of abstract classes implementing the multiton design pattern.
- class 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.