Issue 32337: Dict order is now guaranteed, so add tests and doc for it (original) (raw)

Created on 2017-12-15 18:14 by rhettinger, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4973 merged shangdahao,2017-12-22 10:14
PR 6368 merged miss-islington,2018-04-04 04:56
Messages (11)
msg309060 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2017-12-26 11:25
FYI, Builtin dict is tested for ordering already: https://github.com/python/cpython/blob/13a6c098c215921e35004f9d3a9b70f601e56500/Lib/test/test_ordered_dict.py#L646-L662
msg309114 - (view) Author: shangdahao (shangdahao) * Date: 2017-12-28 01:12
Thanks inada, I removed the tests from the PR.
msg311490 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-02-02 13:38
This part needs editing too, the text and example. https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects
msg311585 - (view) Author: shangdahao (shangdahao) * Date: 2018-02-04 04:13
Thanks zhang, I have updated it in the PR.
msg313624 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-03-11 21:42
Raymond, do you want to review the current state of the PR before 3.7.0b4? Otherwise, I'll probably ask that it be merged as is.
msg314916 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2018-04-04 04:41
I started to add this comment to #33218 but Raymond closed that ticket while I was editing it. In 3.6, dicts preserving insertion order remains an implementation detail that cannot be relied on. It only becomes a guarantee in 3.7. Even in 3.7, I think that it remains best to think of dicts as fundamentally unordered. Dicts might preserve insertion order, but there's no interface for extracting the n-th item, or re-ordering the keys into some alternative order, and for the purposes of equality comparisons, the order is ignored. I propose changing the description from "It is best to think of a dictionary as an unordered set of key: value pairs" to something like: Dicts are an otherwise unordered set of key:value pairs that remember the order keys were inserted. and references to "arbitrary order" should be replaced by "insertion order". But by no means should we suggest that dicts are fundamentally orderable (sortable).
msg314917 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-04-04 04:45
> I started to add this comment to #33218 but Raymond closed that ticket while I was editing it. Sorry, I closed it, not Raymond.
msg314918 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-04-04 04:55
New changeset dfbbbf16f9aab82330c634913441b5ac73267d9c by INADA Naoki (hui shang) in branch 'master': bpo-32337: Update documentats about dict order (GH-4973) https://github.com/python/cpython/commit/dfbbbf16f9aab82330c634913441b5ac73267d9c
msg314920 - (view) Author: miss-islington (miss-islington) Date: 2018-04-04 05:01
New changeset 9216dffbc8a2aa62789f81f51f64bc1ec7bf6883 by Miss Islington (bot) in branch '3.7': bpo-32337: Update documentats about dict order (GH-4973) https://github.com/python/cpython/commit/9216dffbc8a2aa62789f81f51f64bc1ec7bf6883
msg314930 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-04-04 13:55
Any other known issue? May I close this issue?
msg314943 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-04-04 17:36
Thanks for doing this! Let's close it. If comments arise prior to its release in 370b4, we can reopen, otherwise please open a new issue.
History
Date User Action Args
2022-04-11 14:58:55 admin set github: 76518
2018-04-04 17:36:05 ned.deily set status: open -> closedpriority: deferred blocker -> versions: + Python 3.8messages: + resolution: fixedstage: patch review -> resolved
2018-04-04 13:55:21 methane set messages: +
2018-04-04 05:01:48 miss-islington set nosy: + miss-islingtonmessages: +
2018-04-04 04:56:18 miss-islington set pull_requests: + <pull%5Frequest6079>
2018-04-04 04:55:08 methane set messages: +
2018-04-04 04:45:08 methane set messages: +
2018-04-04 04:41:29 steven.daprano set nosy: + steven.dapranomessages: +
2018-04-04 04:24:58 methane link issue33218 superseder
2018-04-03 06:12:08 methane unlink issue32360 dependencies
2018-03-21 09:24:43 eric.smith unlink issue32506 dependencies
2018-03-11 21:42:35 ned.deily set priority: release blocker -> deferred blockermessages: +
2018-03-11 07:06:10 serhiy.storchaka unlink issue32338 dependencies
2018-03-11 07:05:34 serhiy.storchaka set priority: normal -> release blockernosy: + ned.deily
2018-02-04 05:08:20 rhettinger set assignee: rhettinger ->
2018-02-04 04:13:44 shangdahao set messages: +
2018-02-02 13:38:47 xiang.zhang set nosy: + xiang.zhangmessages: +
2018-01-29 20:39:31 rhettinger unlink issue32336 dependencies
2018-01-26 07:39:38 xiang.zhang link issue32673 superseder
2018-01-07 07:47:40 serhiy.storchaka link issue32506 dependencies
2017-12-28 01:12:23 shangdahao set nosy: + shangdahaomessages: +
2017-12-26 11:25:14 methane set nosy: + methanemessages: +
2017-12-22 10:14:56 shangdahao set keywords: + patchstage: needs patch -> patch reviewpull_requests: + <pull%5Frequest4864>
2017-12-18 09:53:57 serhiy.storchaka link issue32360 dependencies
2017-12-18 09:53:44 serhiy.storchaka link issue32338 dependencies
2017-12-18 09:53:28 serhiy.storchaka link issue32336 dependencies
2017-12-15 21:35:31 rhettinger set title: Dict order is now guaranteed, so add tests for it -> Dict order is now guaranteed, so add tests and doc for it
2017-12-15 18:14:10 rhettinger create