-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dict order is now guaranteed, so add tests and doc for it #76518
Comments
FYI, Builtin dict is tested for ordering already: cpython/Lib/test/test_ordered_dict.py Lines 646 to 662 in 13a6c09
|
Thanks inada, I removed the tests from the PR. |
This part needs editing too, the text and example. https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects |
Thanks zhang, I have updated it in the PR. |
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. |
I started to add this comment to bpo-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:
and references to "arbitrary order" should be replaced by "insertion order". But by no means should we suggest that dicts are fundamentally orderable (sortable). |
Sorry, I closed it, not Raymond. |
Any other known issue? May I close this issue? |
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. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: