Browse Source

fix: define `__slots__` to avoid `__dict__` creation

version-14
Sagar Vora 3 years ago
parent
commit
d2dfc8c335
1 changed files with 4 additions and 5 deletions
  1. +4
    -5
      frappe/__init__.py

+ 4
- 5
frappe/__init__.py View File

@@ -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…
Cancel
Save