Common: Improve singleton to use WeakValueDictionary

This commit is contained in:
vakarisz 2022-04-28 17:56:30 +03:00
parent cea49b6d50
commit e51b760af0
1 changed files with 2 additions and 1 deletions

View File

@ -1,5 +1,6 @@
# abstract, static method decorator
# noinspection PyPep8Naming
from weakref import WeakValueDictionary
class abstractstatic(staticmethod):
@ -13,7 +14,7 @@ class abstractstatic(staticmethod):
class Singleton(type):
_instances = {}
_instances = WeakValueDictionary()
def __call__(cls, *args, **kwargs):
if cls not in cls._instances: