Message381971
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'} |
|
Date |
User |
Action |
Args |
2020-11-28 00:50:30 | ap-- | set | recipients:
+ ap-- |
2020-11-28 00:50:30 | ap-- | set | messageid: <1606524630.67.0.897614858795.issue42487@roundup.psfhosted.org> |
2020-11-28 00:50:30 | ap-- | link | issue42487 messages |
2020-11-28 00:50:29 | ap-- | create | |
|