Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Also, dicts can become unordered at any time in the future. Right now the OrderedDict implementation is a thin layer over dict, but there are no guarantees it’ll always be that.


Not true as of 3.7[0]

  the insertion-order preservation nature of dict objects has been declared to be an official part of the Python language spec.
[0] https://docs.python.org/3.7/whatsnew/3.7.html


Oh well... This is what I get to not look at release notes with lawyer eyes. Thanks for the correction.


dict are ordered to keep argument order when using named arguments in function calling. So it would be a non-trivial breaking change to revert this now.

I would argue that OrderedDict have more chances to be depreciated than dict becoming unordered again, since there is now little value to keep OrderedDict around now (and the methods currently specific to UnorderedDict could be added to dict).


They can, but ordered dict can also become unordered in the future, should the steering committee decide.

But seriously: It’s no longer an implementation detail that dictionaries are ordered in Python. It’s a specification of how Python works.


I missed that in the 3.7 release notes.


There in lies another reason why OrderedDicts are still useful even in 3.12


Not really. It was pointed out that since 3.7 the order preserving behaviour is part of the spec for dicts.


I guess for most purposes, OrderedDicts are then obsolete, but I believe there are some extra convenience methods that they have, but I've only really needed to preserve order.

Makes you think what other parts of Python have become obsolete.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: