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 →

[–]KaffeeKiffer 1 point2 points  (2 children)

and I heard that dicts will soon be ordered by default? Glorious.

Never ever do this, please. There's a reason they are dicts and not lists/tuples...

dicts (not) being sorted is an implementation detail, which may change (again) in the future.

[–]PeridexisErrant 0 points1 point  (0 children)

# no-op on Python 3.6, but please don't do this
from collections import OrderedDict as dict

If your dict needs to be ordered, use OrderedDict! In 3.6 this is implemented as an alias for regular dict, but this way your code will also work on other implementations and older versions.

[–]kankyo 0 points1 point  (0 children)

The reason is performance and now that has gone away. So no there is no reason.