[issue9823] OrderedDict is comparable to dict

Ram Rachum report at bugs.python.org
Fri Sep 10 18:15:23 CEST 2010


New submission from Ram Rachum <cool-rr at cool-rr.com>:

OrderedDict is currently comparable to dict.

I think this is not logical, because a dict doesn't have order, and having an identical order is a necessary condition for a match.

I think that comparing an OrderedDict with a dict makes as much sense as comparing a tuple with a set, and that's currently not allowed. (Always returns False)

Here's a disturbing code snippet executed in Python 3.2a1:

>>> from collections import OrderedDict
>>> d1 = OrderedDict(((1, 2), (3, 4)))
>>> d2 = OrderedDict(((3, 4), (1, 2)))
>>> d1 == d2
False
>>> d1 == {1: 2, 3: 4} == d2
True

----------
components: Library (Lib)
messages: 116027
nosy: cool-RR
priority: normal
severity: normal
status: open
title: OrderedDict is comparable to dict
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9823>
_______________________________________


More information about the Python-bugs-list mailing list