This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ap--
Recipients ap--
Date 2020-11-28.00:50:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1606524630.67.0.897614858795.issue42487@roundup.psfhosted.org>
In-reply-to
Content
Hello,

I encountered an issue with collections.ChainMap, that was introduced when https://bugs.python.org/issue32792 got fixed.

Iterating a ChainMap will call __getitem__ on its underlying maps:


>>> from collections import UserDict, ChainMap
>>> class MyDict(UserDict):
...     def __getitem__(self, k):
...         print("expensive computation", k)
...         return super().__getitem__(k)
... 
>>> set(ChainMap(MyDict(a=1, b=2, c=3)))
expensive computation a
expensive computation b
expensive computation c
{'c', 'b', 'a'}
History
Date User Action Args
2020-11-28 00:50:30ap--setrecipients: + ap--
2020-11-28 00:50:30ap--setmessageid: <1606524630.67.0.897614858795.issue42487@roundup.psfhosted.org>
2020-11-28 00:50:30ap--linkissue42487 messages
2020-11-28 00:50:29ap--create