Skip to content

Commit 821b2c0

Browse files
committed
updated singletonMeta class with lru_cache
1 parent 8e38f29 commit 821b2c0

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

netsim_wrapper/common/singleton.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22
Singleton Metaclass
33
"""
44

5-
class SingletonMeta(type):
6-
"""
7-
Singleton Metaclass
8-
"""
95

10-
_instance = None
6+
from functools import lru_cache
7+
118

12-
def __call__(cls, *args, **kwargs):
13-
if not cls._instance:
14-
cls._instance = super().__call__(*args, **kwargs)
15-
return cls._instance
9+
class SingletonMeta(type):
10+
__call__ = lru_cache(type.__call__)

0 commit comments

Comments
 (0)