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):
|
def __iter__(self):
|
||||||
d = {}
|
d = {}
|
||||||
for mapping in reversed(self.maps):
|
for mapping in map(dict.fromkeys, reversed(self.maps)):
|
||||||
d.update(dict.fromkeys(mapping)) # reuses stored hash values if possible
|
d |= mapping # reuses stored hash values if possible
|
||||||
return iter(d)
|
return iter(d)
|
||||||
|
|
||||||
def __contains__(self, key):
|
def __contains__(self, key):
|
||||||
|
|
Loading…
Reference in New Issue