PYTHON-703 Remove slow SON.__contains__ method.
__setitem__ must now check self.__keys to avoid setting keys twice during "copy.copy(son_obj)".
This commit is contained in:
parent
b8c944f118
commit
fd8dd020bc
@ -104,7 +104,7 @@ class SON(dict):
|
||||
return "SON([%s])" % ", ".join(result)
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
if key not in self:
|
||||
if key not in self.__keys:
|
||||
self.__keys.append(key)
|
||||
dict.__setitem__(self, key, value)
|
||||
|
||||
@ -130,9 +130,6 @@ class SON(dict):
|
||||
def has_key(self, key):
|
||||
return key in self.__keys
|
||||
|
||||
def __contains__(self, key):
|
||||
return key in self.__keys
|
||||
|
||||
# third level takes advantage of second level definitions
|
||||
def iteritems(self):
|
||||
for k in self:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user