aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLahfa Samy <lahfa121999@gmail.com>2020-03-26 15:54:04 +0100
committerGitHub <noreply@github.com>2020-03-26 09:54:04 -0500
commit59c644eaa72b0cc48302f59d66852c4ea8332eba (patch)
tree21928eb789f8ab9fb77d4ee805144b81e6beae9b /Doc/reference
parentbpo-40069: Clear out .lst files on make clean (GH-19169) (diff)
downloadcpython-59c644eaa72b0cc48302f59d66852c4ea8332eba.tar.gz
cpython-59c644eaa72b0cc48302f59d66852c4ea8332eba.tar.bz2
cpython-59c644eaa72b0cc48302f59d66852c4ea8332eba.zip
bpo-39879: Update datamodel docs to include dict ordering (GH-19006)
Co-authored-by: furkanonder <furkantahaonder@gmail.com>
Diffstat (limited to 'Doc/reference')
-rw-r--r--Doc/reference/datamodel.rst10
1 files changed, 10 insertions, 0 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index c683d9991eb..e91e855674d 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -425,6 +425,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`).
@@ -436,6 +441,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