classification
Title: Creating dict from OrderedDict doesn't preserve order
Type: behavior Stage: patch review
Components: Interpreter Core Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: 34345 Superseder:
Assigned To: Nosy List: Rosuav, eric.snow, inada.naoki, rhettinger, serhiy.storchaka, steve.dower
Priority: normal Keywords: patch

Created on 2018-08-02 13:12 by serhiy.storchaka, last changed 2018-08-06 12:08 by serhiy.storchaka.

Pull Requests
URL Status Linked Edit
PR 8624 open inada.naoki, 2018-08-02 13:36
Messages (1)
msg322951 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-08-02 13:12
>>> 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})
History
Date User Action Args
2018-08-06 12:08:50serhiy.storchakasetdependencies: + Add tests for PEP 468 and PEP 520
2018-08-02 13:36:05inada.naokisetkeywords: + patch
stage: patch review
pull_requests: + pull_request8129
2018-08-02 13:12:23serhiy.storchakacreate