kkpyutil 1.42.0__tar.gz → 1.43.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kkpyutil-1.42.0 → kkpyutil-1.43.0}/PKG-INFO +1 -1
- {kkpyutil-1.42.0 → kkpyutil-1.43.0}/kkpyutil.py +12 -0
- {kkpyutil-1.42.0 → kkpyutil-1.43.0}/pyproject.toml +1 -1
- {kkpyutil-1.42.0 → kkpyutil-1.43.0}/LICENSE +0 -0
- {kkpyutil-1.42.0 → kkpyutil-1.43.0}/README.md +0 -0
- {kkpyutil-1.42.0 → kkpyutil-1.43.0}/kkpyutil_helper/windows/kkttssave.ps1 +0 -0
- {kkpyutil-1.42.0 → kkpyutil-1.43.0}/kkpyutil_helper/windows/kkttsspeak.ps1 +0 -0
|
@@ -105,6 +105,18 @@ class ClassicSingleton:
|
|
|
105
105
|
raise RuntimeError("Use `cls.instance()` to access the singleton instance.")
|
|
106
106
|
|
|
107
107
|
|
|
108
|
+
class MetaSingleton(type):
|
|
109
|
+
"""
|
|
110
|
+
- usage: class MyClass(metaclass=MetaSingleton)
|
|
111
|
+
"""
|
|
112
|
+
_instances = {}
|
|
113
|
+
|
|
114
|
+
def __call__(cls, *args, **kwargs):
|
|
115
|
+
if cls not in cls._instances:
|
|
116
|
+
cls._instances[cls] = super(MetaSingleton, cls).__call__(*args, **kwargs)
|
|
117
|
+
return cls._instances[cls]
|
|
118
|
+
|
|
119
|
+
|
|
108
120
|
class BorgSingleton:
|
|
109
121
|
"""
|
|
110
122
|
- Borg pattern: all instances share the same state, but not the same identity
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|