Python 3.7 – Dictionaries now ordered

One of my readers pointed out to me that Python 3.7 will now have ordered dictionaries by default. You can read the “announcement” over on the Python-Dev list.

Python’s dict has always been unordered up until Python 3.6, when it was changed to be ordered based on a proposal by Raymond Hettinger, who is one of Python’s core developers.

The release notes for Python 3.6 said the following:

The order-preserving aspect of this new implementation is considered an implementation detail and should not be relied upon (this may change in the future, but it is desired to have this new dict implementation in the language for a few releases before changing the language spec to mandate order-preserving semantics for all current and future Python implementations; this also helps preserve backwards-compatibility with older versions of the language where random iteration order is still in effect, e.g. Python 3.5).

Now when Python 3.7 is released, the ordered implementation of the dict will be the standard. I think this is pretty neat.

Print Friendly, PDF & Email