milvus/shards/utils/__init__.py

19 lines
426 B
Python
Raw Normal View History

2019-10-21 16:21:32 +08:00
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
2019-10-26 16:27:16 +08:00
class dotdict(dict):
"""dot.notation access to dictionary attributes"""
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__