diff options
Diffstat (limited to 'Lib/collections')
-rw-r--r-- | Lib/collections/__init__.py | 14 | ||||
-rw-r--r-- | Lib/collections/abc.py | 3 |
2 files changed, 10 insertions, 7 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index e5f9599..0612e1f 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -228,8 +228,7 @@ class OrderedDict(dict): ''' if isinstance(other, OrderedDict): - return len(self)==len(other) and \ - all(map(_eq, self.items(), other.items())) + return dict.__eq__(self, other) and all(map(_eq, self, other)) return dict.__eq__(self, other) @@ -822,9 +821,14 @@ class ChainMap(MutableMapping): __copy__ = copy - def new_child(self): # like Django's Context.push() - 'New ChainMap with a new dict followed by all previous maps.' - return self.__class__({}, *self.maps) + def new_child(self, m=None): # like Django's Context.push() + ''' + New ChainMap with a new map followed by all previous maps. If no + map is provided, an empty dict is used. + ''' + if m is None: + m = {} + return self.__class__(m, *self.maps) @property def parents(self): # like Django's Context.pop() diff --git a/Lib/collections/abc.py b/Lib/collections/abc.py index c23b7dd..18c07bf 100644 --- a/Lib/collections/abc.py +++ b/Lib/collections/abc.py @@ -430,8 +430,7 @@ class KeysView(MappingView, Set): return key in self._mapping def __iter__(self): - for key in self._mapping: - yield key + yield from self._mapping KeysView.register(dict_keys) |