forked from p15670423/monkey
Common: Improve singleton to use WeakValueDictionary
This commit is contained in:
parent
cea49b6d50
commit
e51b760af0
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue