https://github.com/python/cpython/commit/cc588aaa5f9cd0e412fe6cc434f74c0039937418
commit: cc588aaa5f9cd0e412fe6cc434f74c0039937418
branch: 3.14
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: terryjreedy <tjre...@udel.edu>
date: 2025-05-07T22:10:51Z
summary:

[3.14] gh-133361: move the explanation of dict equal before its use (GH-133424) 
(#133620)

gh-133361: move the explanation of dict equal before its use (GH-133424)

Also move up the explanation of insertion order preservation.  Both paragraphs 
seemed out of place down where they were.
---------
(cherry picked from commit 61ac88c06e0286cfc6465a47552d41b7dd7e083e)

Co-authored-by: Yongzi Li <1538321...@qq.com>
Co-authored-by: Terry Jan Reedy <tjre...@udel.edu>

files:
M Doc/library/stdtypes.rst

diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 39aaa5da0786f8..61d39a6671caed 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -4823,7 +4823,13 @@ can be used interchangeably to index the same dictionary 
entry.
    being added is already present, the value from the keyword argument
    replaces the value from the positional argument.
 
-   To illustrate, the following examples all return a dictionary equal to
+   Providing keyword arguments as in the first example only works for keys that
+   are valid Python identifiers.  Otherwise, any valid keys can be used.
+
+   Dictionaries compare equal if and only if they have the same ``(key,
+   value)`` pairs (regardless of ordering). Order comparisons ('<', '<=', 
'>=', '>') raise
+   :exc:`TypeError`.  To illustrate dictionary creation and equality,
+   the following examples all return a dictionary equal to
    ``{"one": 1, "two": 2, "three": 3}``::
 
       >>> a = dict(one=1, two=2, three=3)
@@ -4838,6 +4844,27 @@ can be used interchangeably to index the same dictionary 
entry.
    Providing keyword arguments as in the first example only works for keys that
    are valid Python identifiers.  Otherwise, any valid keys can be used.
 
+   Dictionaries preserve insertion order.  Note that updating a key does not
+   affect the order.  Keys added after deletion are inserted at the end. ::
+
+      >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}
+      >>> d
+      {'one': 1, 'two': 2, 'three': 3, 'four': 4}
+      >>> list(d)
+      ['one', 'two', 'three', 'four']
+      >>> list(d.values())
+      [1, 2, 3, 4]
+      >>> d["one"] = 42
+      >>> d
+      {'one': 42, 'two': 2, 'three': 3, 'four': 4}
+      >>> del d["two"]
+      >>> d["two"] = None
+      >>> d
+      {'one': 42, 'three': 3, 'four': 4, 'two': None}
+
+   .. versionchanged:: 3.7
+      Dictionary order is guaranteed to be insertion order.  This behavior was
+      an implementation detail of CPython from 3.6.
 
    These are the operations that dictionaries support (and therefore, custom
    mapping types should support too):
@@ -5008,32 +5035,6 @@ can be used interchangeably to index the same dictionary 
entry.
 
       .. versionadded:: 3.9
 
-   Dictionaries compare equal if and only if they have the same ``(key,
-   value)`` pairs (regardless of ordering). Order comparisons ('<', '<=', 
'>=', '>') raise
-   :exc:`TypeError`.
-
-   Dictionaries preserve insertion order.  Note that updating a key does not
-   affect the order.  Keys added after deletion are inserted at the end. ::
-
-      >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}
-      >>> d
-      {'one': 1, 'two': 2, 'three': 3, 'four': 4}
-      >>> list(d)
-      ['one', 'two', 'three', 'four']
-      >>> list(d.values())
-      [1, 2, 3, 4]
-      >>> d["one"] = 42
-      >>> d
-      {'one': 42, 'two': 2, 'three': 3, 'four': 4}
-      >>> del d["two"]
-      >>> d["two"] = None
-      >>> d
-      {'one': 42, 'three': 3, 'four': 4, 'two': None}
-
-   .. versionchanged:: 3.7
-      Dictionary order is guaranteed to be insertion order.  This behavior was
-      an implementation detail of CPython from 3.6.
-
    Dictionaries and dictionary views are reversible. ::
 
       >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to