Dictionary order?
Dan Stromberg
drsalists at gmail.com
Mon Aug 1 19:46:51 EDT 2022
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.
More information about the Python-list
mailing list