MCPcopy Create free account
hub / github.com/DasyDong/developer-roadmap / singleton

Function singleton

code/run_class.py:2–9  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

1
2def singleton(cls):
3 instances = {}
4
5 def wrapper(*args, **kwargs):
6 if 'cls' not in instances:
7 instances['cls'] = cls(*args, **kwargs)
8 return instances['cls']
9 return wrapper
10
11
12@singleton

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected