[New-bugs-announce] [issue24286] Should OrderedDict.viewitems compare equal to dict.viewitems when the items are equal?

Joshua Bronson report at bugs.python.org
Tue May 26 01:28:07 CEST 2015


New submission from Joshua Bronson:

Is it intentional that the second assertion in the following code fails?

```
from collections import OrderedDict

d = dict(C='carbon')
o = OrderedDict(d)
assert d == o
assert d.viewitems() == o.viewitems()
```

Since d == o, I'm surprised that d.viewitems() != o.viewitems(). If that's intentional, I'd love to understand the rationale.

Note: I hit this while testing a library I authored, https://pypi.python.org/pypi/bidict, which provides a https://en.wikipedia.org/wiki/Bidirectional_map implementation for Python, so I'm especially keen to understand all the subtleties in this area.

Thanks in advance.

----------
messages: 244066
nosy: jab
priority: normal
severity: normal
status: open
title: Should OrderedDict.viewitems compare equal to dict.viewitems when the items are equal?
versions: Python 2.7

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


More information about the New-bugs-announce mailing list