mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
bpo-39879: Update datamodel docs to include dict ordering (GH-19006)
Co-authored-by: furkanonder <furkantahaonder@gmail.com>
This commit is contained in:
parent
1b6b0e78fe
commit
59c644eaa7
3 changed files with 13 additions and 0 deletions
|
@ -425,6 +425,11 @@ Mappings
|
||||||
equal (e.g., ``1`` and ``1.0``) then they can be used interchangeably to index
|
equal (e.g., ``1`` and ``1.0``) then they can be used interchangeably to index
|
||||||
the same dictionary entry.
|
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
|
Dictionaries are mutable; they can be created by the ``{...}`` notation (see
|
||||||
section :ref:`dict`).
|
section :ref:`dict`).
|
||||||
|
|
||||||
|
@ -436,6 +441,11 @@ Mappings
|
||||||
additional examples of mapping types, as does the :mod:`collections`
|
additional examples of mapping types, as does the :mod:`collections`
|
||||||
module.
|
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
|
Callable types
|
||||||
.. index::
|
.. index::
|
||||||
object: callable
|
object: callable
|
||||||
|
|
|
@ -39,6 +39,7 @@ Ray Allen
|
||||||
Billy G. Allie
|
Billy G. Allie
|
||||||
Jamiel Almeida
|
Jamiel Almeida
|
||||||
Kevin Altis
|
Kevin Altis
|
||||||
|
Samy Lahfa
|
||||||
Skyler Leigh Amador
|
Skyler Leigh Amador
|
||||||
Joe Amenta
|
Joe Amenta
|
||||||
Rose Ames
|
Rose Ames
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Updated :ref:`datamodel` docs to include :func:`dict` insertion order preservation.
|
||||||
|
Patch by Furkan Onder and Samy Lahfa.
|
Loading…
Add table
Add a link
Reference in a new issue