mirror of https://github.com/python/cpython
GH-98766: Modest speed-up from ChainMap.__iter__ (GH-98946)
This commit is contained in:
parent
5cf317ade1
commit
f5afb7f233
|
@ -1011,8 +1011,8 @@ class ChainMap(_collections_abc.MutableMapping):
|
|||
|
||||
def __iter__(self):
|
||||
d = {}
|
||||
for mapping in reversed(self.maps):
|
||||
d.update(dict.fromkeys(mapping)) # reuses stored hash values if possible
|
||||
for mapping in map(dict.fromkeys, reversed(self.maps)):
|
||||
d |= mapping # reuses stored hash values if possible
|
||||
return iter(d)
|
||||
|
||||
def __contains__(self, key):
|
||||
|
|
Loading…
Reference in New Issue