cutcutcodec.core.opti.cache.singleton
Allow to create only one instance of an object.
Classes
For share memory inside the current session. |
Details
- class cutcutcodec.core.opti.cache.singleton.MetaSingleton[source]
For share memory inside the current session.
Notes
The arguments needs to be hashable.
Examples
>>> from cutcutcodec.core.opti.cache.singleton import MetaSingleton >>> class A: ... pass ... >>> class B(metaclass=MetaSingleton): ... pass ... >>> class C(metaclass=MetaSingleton): ... def __init__(self, *args, **kwargs): ... self.args = args ... self.kwargs = kwargs ... >>> A() is A() False >>> B() is B() True >>> C(0) is C(0) True >>> C(0) is C(1) False >>>