Dictionary order?

Weatherby,Gerard gweatherby at uchc.edu
Mon Aug 1 21:14:43 EDT 2022


I don’t see what is surprising. The interface for a dictionary never specified the ordering of the keys, so I would not be surprised to see it vary based on release, platform, values of keys inserted, number of items in the dictionary, etc.





—
Gerard Weatherby | Application Architect NMRbox | NAN | Department of Molecular Biology and Biophysics
 UConn Health 263 Farmington Avenue, Farmington, CT 06030-6406 uchc.edu
On Aug 1, 2022, 7:48 PM -0400, Dan Stromberg <drsalists at gmail.com>, wrote:
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

On Mon, Aug 1, 2022 at 4:42 PM Dan Stromberg <drsalists at gmail.com> wrote:


Yes, but I'm pretty sure that's been true for a LONG time. The hashes
for small integers have been themselves for as long as I can remember.
But the behaviour of the dictionary, when fed such keys, is what's
changed.

I'm not disputing either of those facts. I'm pointing out that the
apparently arbitrary order of a mapping's keys becomes obvious when you
look at the hashes of those keys.


It looks like the relationship no longer holds at around keys =
list(range(250, 260))

But i == hash(i) holds for the first million values at least.


I could've been more clear. int dict keys stop being stored-in-order at
near 256.

But i == hash(i) holds for the first million values, and probably more.

This suggests to me that there's something more than i == hash(i) going on
inside dict's - but it doesn't much matter what it is for my purposes.
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!j3p_Aq5MoGqDk5XMsKb4SKs3U1nfuMOx0wVkSa_hbURJ22w6lP8NrCOc_PYAfELYOdVlC9x6JzLfIMIw5sLe$


More information about the Python-list mailing list