This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Document that dicts preserve insertion order
Type: Stage: resolved
Components: Documentation Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Eric Atkin, cheryl.sabella, docs@python, methane, miss-islington, nascheme, ned.deily, vstinner, yselivanov
Priority: high Keywords: patch

Created on 2018-05-22 21:07 by yselivanov, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 7093 merged methane, 2018-05-24 09:06
PR 7407 merged miss-islington, 2018-06-04 22:09
PR 7485 merged nascheme, 2018-06-07 16:14
PR 7497 merged miss-islington, 2018-06-07 21:47
Messages (11)
msg317346 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-05-22 21:07
I don't see it documented that dicts preserve insertion order. 3.7 what's new points to [1], but that section doesn't have a "version changed" tag.

IMO, [1] should have two version changed tags: one for 3.6, and one for 3.7.

Also, it would be great if we could document how the order is preserved when a key is deleted from the dict etc.

[1] https://docs.python.org/3.7/library/stdtypes.html#mapping-types-dict
msg317423 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2018-05-23 16:23
As reference, issue32337 made some changes documenting that the dicts preserve insertion order.  Also, issue33218 was marked as being superseded by #32337.
msg317454 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-05-23 20:41
I agree with Yury's suggestions; the entry in the "Dictionary view objects" section, that Cheryl points to, is not sufficient.  Is somebody willing to write a PR?
msg318715 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-06-04 22:09
New changeset f822549653d8d09bffff5b7dcddfdf12679a787c by Ned Deily (INADA Naoki) in branch 'master':
bpo-33609: Document dict insertion order guarantee as of 3.7 (GH-7093)
https://github.com/python/cpython/commit/f822549653d8d09bffff5b7dcddfdf12679a787c
msg318717 - (view) Author: miss-islington (miss-islington) Date: 2018-06-04 22:25
New changeset 8585ec9b761947aae6be5f653a5b9ddef2801d58 by Miss Islington (bot) in branch '3.7':
bpo-33609: Document dict insertion order guarantee as of 3.7 (GH-7093)
https://github.com/python/cpython/commit/8585ec9b761947aae6be5f653a5b9ddef2801d58
msg318718 - (view) Author: Neil Schemenauer (nascheme) * (Python committer) Date: 2018-06-04 22:27
The wording sounds strange to me.  Currently it is:
> Note that updating key doesn't affects the order ...

I would say:
> Note that updating a key does not affect the order ...
msg318719 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-06-04 22:30
Neil, that looks like a perfect opportunity to use the GitHub web interface to make that edit :)
msg318973 - (view) Author: Neil Schemenauer (nascheme) * (Python committer) Date: 2018-06-07 21:46
New changeset d3ed67d14ed401dfe2b5d07b6941adc3ecacb268 by Neil Schemenauer in branch 'master':
bpo-33609: small wording fixes to dict ordering docs
https://github.com/python/cpython/commit/d3ed67d14ed401dfe2b5d07b6941adc3ecacb268
msg319000 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-06-08 00:38
New changeset 9b0d4d04a15a97a1055f1b729f14e9257f149fd3 by Yury Selivanov (Miss Islington (bot)) in branch '3.7':
bpo-33609: small wording fixes to dict ordering docs (#7497)
https://github.com/python/cpython/commit/9b0d4d04a15a97a1055f1b729f14e9257f149fd3
msg324951 - (view) Author: Eric Atkin (Eric Atkin) Date: 2018-09-10 19:06
It seems the note at the bottom for `object.__hash__(self)` [1] should be updated as well.

[1] https://docs.python.org/3/reference/datamodel.html#object.__hash__
msg358863 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-12-25 13:36
GH-9807 fixed it.
History
Date User Action Args
2022-04-11 14:59:00adminsetgithub: 77790
2019-12-25 13:36:44methanesetstatus: open -> closed
resolution: fixed
messages: + msg358863

stage: patch review -> resolved
2018-09-10 19:06:49Eric Atkinsetnosy: + Eric Atkin
messages: + msg324951
2018-06-08 00:38:25yselivanovsetmessages: + msg319000
2018-06-07 21:47:23miss-islingtonsetpull_requests: + pull_request7122
2018-06-07 21:46:14naschemesetmessages: + msg318973
2018-06-07 16:14:52naschemesetpull_requests: + pull_request7110
2018-06-04 22:30:54ned.deilysetmessages: + msg318719
2018-06-04 22:27:42naschemesetnosy: + nascheme
messages: + msg318718
2018-06-04 22:25:14miss-islingtonsetnosy: + miss-islington
messages: + msg318717
2018-06-04 22:09:40miss-islingtonsetpull_requests: + pull_request7033
2018-06-04 22:09:33ned.deilysetmessages: + msg318715
2018-05-24 09:06:45methanesetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request6729
2018-05-23 20:41:22ned.deilysetpriority: normal -> high
type: enhancement ->
messages: + msg317454

stage: needs patch
2018-05-23 16:23:06cheryl.sabellasetnosy: + cheryl.sabella
messages: + msg317423
2018-05-22 21:07:30yselivanovcreate