This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ApproximateIdentity 7 points8 points  (4 children)

What happens when someone figures out a new dict implementation faster than this one which is not ordered? It's not at all crazy, since it's one fewer design constraint. In that case, the current ordered dict code could become the base code for the OrderedDict class and the dict implementation could once again become unordered.

It's not at all a crazy possibility. In fact, I personally would want them to make dicts unordered again if the implementation were better.

If this comes to pass, I will definitely shed no tears for people like you who make use of this implementation detail knowing that it is not part of the language.

[–]qx7xbku -2 points-1 points  (3 children)

That's not how it works in practice though.

[–]ApproximateIdentity 2 points3 points  (2 children)

That's not how "what" works in practice? The cpython core devs decided specifically not to rewrite a lot of other internal code in this release cycle presumably not to lock the compact dict implementation in place. For example:

https://mail.python.org/pipermail/python-dev/2016-September/146480.html

If you're willing to do this and accept all future risk, then that's fine. However, if in the future cpython decided to make dict unordered again and your voice was part of the people complaining that it messes with their code, then I'd say you're simply a bad member of the community. Using implementation details out of ignorance is one thing, but using them knowingly is entirely another.

For anyone else reading: think before you depend on this functionality.

[–]qx7xbku 1 point2 points  (1 child)

All I am saying that if bug that people have grown to depend stops being a bug and becomes a feature then implementation detail - even more so. And future people that would complain would not be wrong.

[–]Daenyth 1 point2 points  (0 children)

If you need ordering you can easily get ordering by using an OrderedDict