diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index 58607874be93d6..f07ee143a5aff1 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -1011,8 +1011,8 @@ def __len__(self): 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):