Dictionary order?

Skip Montanaro skip.montanaro at gmail.com
Mon Aug 1 16:48:45 EDT 2022


>
> So I decided to write a little test program to run on a variety of
> CPythons, to confirm what I was thinking.
>
> And instead I got a surprise.
>
> On 1.4 through 2.1 I got descending key order.  I expected the keys to be
> scattered, but they weren't.
>
> On 2.2 through 3.5 I got ascending key order.  I expected the keys to be
> scattered, but they weren't.
>
> On 3.6 through 3.10 I got insertion order, as expected.
>
> But why are 1.4 through 3.5 ordering so much?
>

That's long in the past, but I seem to recall that key order was
unspecified. That would give the implementer (likely Tim Peters much of the
time) the freedom to do whatever worked best for performance or simplicity
of implementation.

Skip

>


More information about the Python-list mailing list