Is numeric keys of Python's dictionary automatically sorted?

Ant antroy at gmail.com
Wed Mar 7 15:41:40 EST 2007


On Mar 7, 8:18 pm, "John" <rds1... at sh163.net> wrote:
...
> However, I am not sure whether it is always like this. Can anybody confirm
> my finding?

>From the standard library docs:

"Keys and values are listed in an arbitrary order which is non-random,
varies across Python implementations, and depends on the dictionary's
history of insertions and deletions."

i.e. the behaviour you have discovered is an implementation detail,
and could change in future versions.




More information about the Python-list mailing list