[Python-checkins] bpo-39879: Update datamodel docs to include dict ordering (GH-19006)

Miss Islington (bot) webhook-mailer at python.org
Thu Mar 26 10:59:47 EDT 2020


https://github.com/python/cpython/commit/ea0eeb8d3a0544334f8836c98a761b2e3df2bd94
commit: ea0eeb8d3a0544334f8836c98a761b2e3df2bd94
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020年03月26日T07:59:40-07:00
summary:
bpo-39879: Update datamodel docs to include dict ordering (GH-19006)
Co-authored-by: furkanonder <furkantahaonder at gmail.com>
(cherry picked from commit 59c644eaa72b0cc48302f59d66852c4ea8332eba)
Co-authored-by: Lahfa Samy <lahfa121999 at gmail.com>
files:
A Misc/NEWS.d/next/Documentation/2020-03-16-18-12-02.bpo-39879.CnQ7Cv.rst
M Doc/reference/datamodel.rst
M Misc/ACKS
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 1212dc61f2d24..6bd77176d0de3 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -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`).
 
@@ -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
diff --git a/Misc/ACKS b/Misc/ACKS
index 2107435cf093b..684d18ac1c558 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -37,6 +37,7 @@ Ray Allen
 Billy G. Allie
 Jamiel Almeida
 Kevin Altis
+Samy Lahfa
 Skyler Leigh Amador
 Joe Amenta
 Rose Ames
diff --git a/Misc/NEWS.d/next/Documentation/2020-03-16-18-12-02.bpo-39879.CnQ7Cv.rst b/Misc/NEWS.d/next/Documentation/2020-03-16-18-12-02.bpo-39879.CnQ7Cv.rst
new file mode 100644
index 0000000000000..6698ed607ca0e
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2020-03-16-18-12-02.bpo-39879.CnQ7Cv.rst
@@ -0,0 +1,2 @@
+Updated :ref:`datamodel` docs to include :func:`dict` insertion order preservation.
+Patch by Furkan Onder and Samy Lahfa.


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /