Message311989
> The code in msg311969 doesn't reuse hash values.
That doesn't make sense. The dict.update() method reuses the hashes of the input mappings when possible.
>>> from collections import ChainMap
>>> class Int(int):
def __hash__(self):
print(f'Hashing {self}', file=sys.stderr)
return int.__hash__(self)
>>> import sys
>>> d = { Int(1): 'f1', Int(2): 'f2' }
Hashing 1
Hashing 2
>>> e = { Int(1): 's1', Int(3): 's3' }
Hashing 1
Hashing 3
>>> c = ChainMap(d, e)
>>> list(c) # Note, no calls to hash() were made
[1, 3, 2] |
|
Date |
User |
Action |
Args |
2018-02-11 09:18:22 | rhettinger | set | recipients:
+ rhettinger, ned.deily, serhiy.storchaka |
2018-02-11 09:18:22 | rhettinger | set | messageid: <1518340702.19.0.467229070634.issue32792@psf.upfronthosting.co.za> |
2018-02-11 09:18:22 | rhettinger | link | issue32792 messages |
2018-02-11 09:18:21 | rhettinger | create | |
|