On Tue, 2 Aug 2022 at 06:50, Skip Montanaro <skip.montan...@gmail.com> wrote: > > > > > 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. >
One thing that you might notice also is that using strings as keys will begin randomizing them with Python 3.3. But other than strings, it's always been "arbitrary" rather than "random". ChrisA -- https://mail.python.org/mailman/listinfo/python-list