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 rhettinger
Recipients ned.deily, rhettinger, serhiy.storchaka
Date 2018-02-11.09:18:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1518340702.19.0.467229070634.issue32792@psf.upfronthosting.co.za>
In-reply-to
Content
> 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]
History
Date User Action Args
2018-02-11 09:18:22rhettingersetrecipients: + rhettinger, ned.deily, serhiy.storchaka
2018-02-11 09:18:22rhettingersetmessageid: <1518340702.19.0.467229070634.issue32792@psf.upfronthosting.co.za>
2018-02-11 09:18:22rhettingerlinkissue32792 messages
2018-02-11 09:18:21rhettingercreate