Asked By – James Hiew
From the Python 3.7 changelog:
Would this mean that
OrderedDict will become redundant? The only use I can think of it will be to maintain backwards compatibility with older versions of Python which don’t preserve insertion-order for normal dictionaries.
Now we will see solution for issue: Will OrderedDict become redundant in Python 3.7?
No it won’t become redundant in Python 3.7 because
OrderedDict is not just a
dict that retains insertion order, it also offers an order dependent method,
OrderedDict.move_to_end(), and supports
Moreover, equality comparisons with
OrderedDict are order sensitive and this is still not the case for
dict in Python 3.7, for example:
>>> OrderedDict([(1,1), (2,2)]) == OrderedDict([(2,2), (1,1)]) False >>> dict([(1,1), (2,2)]) == dict([(2,2), (1,1)]) True
* Support for
reversed() iteration of regular Python
dict is added for Python 3.8, see issue33462