[Python-Dev] Intricacies of calling __eq__

Maciej Fijalkowski fijall at gmail.com
Fri Mar 21 19:48:00 CET 2014


On Wed, Mar 19, 2014 at 11:43 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>
> 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.
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/fijall%40gmail.com
>

at the end of the day we settled for dicts with str int or identity
keys, so we're perfectly safe


More information about the Python-Dev mailing list