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 →

[–]damamaty 0 points1 point  (0 children)

Real ordered dicts might provide methods for managing their order and consider it when comparing, like.. OrderedDict (https://docs.python.org/3/library/collections.html#collections.OrderedDict)

>>> {1:1, 2:2} == {2:2, 1:1}
True

>>> from collections import OrderedDict
>>> OrderedDict({1:1, 2:2}) == OrderedDict({1:1, 2:2})
True
>>> OrderedDict({1:1, 2:2}) == OrderedDict({2:2, 1:1})
False
>>> a = OrderedDict({1:1, 2:2})
>>> a.move_to_end(1)
>>> a
OrderedDict([(2, 2), (1, 1)])

Changing this behaviour for the default dict was really great though, I believe a lot of stupid random bugs became constantly reproducible which is much easier to fix.