[New-bugs-announce] [issue34320] Creating dict from OrderedDict doesn't preserve order

Serhiy Storchaka report at bugs.python.org
Thu Aug 2 09:12:23 EDT 2018


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

>>> from collections import OrderedDict
>>> od = OrderedDict([('a', 1), ('b', 2)])
>>> od.move_to_end('a')
>>> od
OrderedDict([('b', 2), ('a', 1)])
>>> dict(od)
{'a': 1, 'b': 2}

This affects also PEP 468.

>>> def f(**kwargs): return kwargs
... 
>>> f(**od)
{'a': 1, 'b': 2}

And PEP 520.

>>> type('A', (), od).__dict__
mappingproxy({'a': 1, 'b': 2, '__module__': '__main__', '__dict__': <attribute '__dict__' of 'A' objects>, '__weakref__': <attribute '__weakref__' of 'A' objects>, '__doc__': None})

----------
components: Interpreter Core
messages: 322951
nosy: Rosuav, eric.snow, inada.naoki, rhettinger, serhiy.storchaka, steve.dower
priority: normal
severity: normal
status: open
title: Creating dict from OrderedDict doesn't preserve order
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34320>
_______________________________________


More information about the New-bugs-announce mailing list