classification
Title: OderedDict.viewitems() does not preserve item order
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: luch, rhettinger
Priority: normal Keywords:

Created on 2010-08-17 13:14 by luch, last changed 2010-08-17 19:05 by rhettinger. This issue is now closed.

Messages (2)
msg114117 - (view) Author: Alexey Luchko (luch) Date: 2010-08-17 13:14
OrderedDict.viewitems() is expected to preserve item order like items() do
>>> from collections import OrderedDict
>>> d = OrderedDict([(1, 2), ("a", "b")])
>>> d.items()
[(1, 2), ('a', 'b')]

But it does not:
>>> list(d.viewitems())
[('a', 'b'), (1, 2)]
msg114146 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-08-17 19:05
The effort to backport dictviews was incomplete.
Fixed in r84148.
Thanks for the report.
History
Date User Action Args
2010-08-17 19:05:01rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg114146
2010-08-17 13:47:03benjamin.petersonsetassignee: rhettinger

nosy: + rhettinger
2010-08-17 13:14:33luchcreate