The Order Of Dictionary Entries

Aahz aahz at
Wed Mar 10 12:57:58 CET 2004

In article <in93i1-ctp1.ln1 at>,
Tim Daneliuk  <tundra at> wrote:
>I am aware that dictionary order is not guaranteed.  But I ran into
>something puzzling today.  I filled a dictionary dynamically as a
>program ran.  Up to a certain point, the key order was the order
>in which things were added.  However, at some point, the dictionary
>appeared to reorder its contents in some non-deterministic way - in
>fact, it looked like it was putting all the uppercase keys first,
>followed by lowercase keys.
>I'm just curious, just what _is_ the approach used for ordering
>dictionary keys?

Use the source, Luke.  See Objects/dictobject.c

Hint: dicts are based on hashing.
Aahz (aahz at           <*>

"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python

More information about the Python-list mailing list