mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-01 11:29:48 +08:00
19 lines
426 B
Python
19 lines
426 B
Python
from functools import wraps
|
|
|
|
|
|
def singleton(cls):
|
|
instances = {}
|
|
@wraps(cls)
|
|
def getinstance(*args, **kw):
|
|
if cls not in instances:
|
|
instances[cls] = cls(*args, **kw)
|
|
return instances[cls]
|
|
return getinstance
|
|
|
|
|
|
class dotdict(dict):
|
|
"""dot.notation access to dictionary attributes"""
|
|
__getattr__ = dict.get
|
|
__setattr__ = dict.__setitem__
|
|
__delattr__ = dict.__delitem__
|