fix: define __slots__ to avoid __dict__ creation
This commit is contained in:
parent
594e653347
commit
d2dfc8c335
1 changed files with 4 additions and 5 deletions
|
|
@ -55,20 +55,19 @@ controllers = {}
|
|||
class _dict(dict):
|
||||
"""dict like object that exposes keys as attributes"""
|
||||
|
||||
__slots__ = ()
|
||||
__getattr__ = dict.get
|
||||
__setattr__ = dict.__setitem__
|
||||
__delattr__ = dict.__delitem__
|
||||
__setstate__ = dict.update
|
||||
|
||||
def __getstate__(self):
|
||||
return self
|
||||
|
||||
def __setstate__(self, d):
|
||||
self.update(d)
|
||||
|
||||
def update(self, d):
|
||||
def update(self, *args, **kwargs):
|
||||
"""update and return self -- the missing dict feature in python"""
|
||||
|
||||
super().update(d)
|
||||
super().update(*args, **kwargs)
|
||||
return self
|
||||
|
||||
def copy(self):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue