Skip to content

[3.8] bpo-39879: Update datamodel docs to include dict ordering (GH-19006) #19173

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

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ Mappings
equal (e.g., ``1`` and ``1.0``) then they can be used interchangeably to index
the same dictionary entry.

Dictionaries preserve insertion order, meaning that keys will be produced
in the same order they were added sequentially over the dictionary.
Replacing an existing key does not change the order, however removing a key
and re-inserting it will add it to the end instead of keeping its old place.

Dictionaries are mutable; they can be created by the ``{...}`` notation (see
section :ref:`dict`).

Expand All @@ -431,6 +436,11 @@ Mappings
additional examples of mapping types, as does the :mod:`collections`
module.

.. versionchanged:: 3.7
Dictionaries did not preserve insertion order in versions of Python before 3.6.
In CPython 3.6, insertion order was preserved, but it was considered
an implementation detail at that time rather than a language guarantee.

Callable types
.. index::
object: callable
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Ray Allen
Billy G. Allie
Jamiel Almeida
Kevin Altis
Samy Lahfa
Skyler Leigh Amador
Joe Amenta
Rose Ames
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Updated :ref:`datamodel` docs to include :func:`dict` insertion order preservation.
Patch by Furkan Onder and Samy Lahfa.