[New-bugs-announce] [issue43691] Comparison of OrderedDict() and dict()

Марк Коренберг report at bugs.python.org
Thu Apr 1 05:42:56 EDT 2021

New submission from Марк Коренберг <socketpair at gmail.com>:

OrderedDict([(1,2), (3,4)]) == OrderedDict([(3,4), (1,2)])
Out[1]: False    # OK

dict([(1,2), (3,4)]) == dict([(3,4), (1,2)])
Out[2]: True     # OK

dict([(1,2), (3,4)]) == OrderedDict([(3,4), (1,2)])
Out[3]: True     # NOT OK, since actual order is different

OrderedDict([(1,2), (3,4)]) == dict([(3,4), (1,2)])
Out[4]: True     # NOT OK, since actual orderd is different

I propose two options to fix it:

1. Return True when comparing anything with OrderedDict iff order is the same.
2. Raise TypeError when someone tries to compare OrderedDict() and dict(). # I think it's better.

components: Library (Lib)
messages: 389965
nosy: socketpair
priority: normal
severity: normal
status: open
title: Comparison of OrderedDict() and dict()
type: behavior
versions: Python 3.10, Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list