[Python-Dev] Intricacies of calling __eq__

Nick Coghlan ncoghlan at gmail.com
Wed Mar 19 22:43:01 CET 2014


On 20 Mar 2014 07:38, "Nick Coghlan" <ncoghlan at gmail.com> wrote:
>
> Correct, but I think this discussion has established that "how many times
dict lookup calls __eq__ on the key" is one such thing. In CPython, it
already varies based on:
>
> - dict contents (due to the identity check and the distribution of
entries across hash buckets)
> - pointer size (due to the hash bucket distribution differing between 32
bit and 64 bit builds)
> - dict tuning parameters (there are some settings in the dict
implementation that affect when dicts resize up and down, etc, which can
mean the hash bucket distribution may already change without much notice in
feature releases)

I just realised that hash randomisation also comes into play here - the
distribution of entries across hash buckets is inherently variable between
runs for any key types that rely directly or indirectly on a randomised
hash.

Cheers,
Nick.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140320/d93b4ad6/attachment.html>


More information about the Python-Dev mailing list