Skip to content

Commit f5afb7f

Browse files
authored
GH-98766: Modest speed-up from ChainMap.__iter__ (GH-98946)
1 parent 5cf317a commit f5afb7f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/collections/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,8 +1011,8 @@ def __len__(self):
10111011

10121012
def __iter__(self):
10131013
d = {}
1014-
for mapping in reversed(self.maps):
1015-
d.update(dict.fromkeys(mapping)) # reuses stored hash values if possible
1014+
for mapping in map(dict.fromkeys, reversed(self.maps)):
1015+
d |= mapping # reuses stored hash values if possible
10161016
return iter(d)
10171017

10181018
def __contains__(self, key):

0 commit comments

Comments
 (0)