[Python-Dev] the new(-ish) dict ordering vs hash randomization
solipsis at pitrou.net
Mon Jun 18 09:21:40 EDT 2018
On Mon, 18 Jun 2018 06:13:15 -0700
Ethan Furman <ethan at stoneleaf.us> wrote:
> I'm sure we've already had this conversation, but my google-fu is failing me.
> Can someone provide a link to a discussion explaining why the new ordering of dictionaries does not defeat the
> hash-randomization non-ordering we added a few versions ago?
Because the aim of hash randomization was not to make iteration order
unpredictable, it was to make hash collisions unpredictable.
The solution used to make hash collisions unpredictable was to make
hash values themselves unpredictable, and that had the side effect of
also making iteration order unpredictable.
But the new dict implementation is able to provide a deterministic
iteration order even with non-deterministic hash values.
More information about the Python-Dev