[Python-checkins] bpo-36144: Document PEP 584 (GH-18659)
Brandt Bucher
webhook-mailer at python.org
Wed Feb 26 15:01:55 EST 2020
https://github.com/python/cpython/commit/d0ca9bd93bb9d8d4aa9bbe939ca7fd54ac870c8f
commit: d0ca9bd93bb9d8d4aa9bbe939ca7fd54ac870c8f
branch: master
author: Brandt Bucher <brandtbucher at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-02-26T12:01:48-08:00
summary:
bpo-36144: Document PEP 584 (GH-18659)
files:
M Doc/library/stdtypes.rst
M Doc/whatsnew/3.9.rst
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 47d64f1e8d65f..435ba5b74ff34 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -4392,6 +4392,22 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
>>> d.values() == d.values()
False
+ .. describe:: d | other
+
+ Create a new dictionary with the merged keys and values of *d* and
+ *other*, which must both be dictionaries. The values of *other* take
+ priority when *d* and *other* share keys.
+
+ .. versionadded:: 3.9
+
+ .. describe:: d |= other
+
+ Update the dictionary *d* with keys and values from *other*, which may be
+ either a :term:`mapping` or an :term:`iterable` of key/value pairs. The
+ values of *other* take priority when *d* and *other* share keys.
+
+ .. 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`.
diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index d3b35fcff5c43..8ad26d6978605 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -70,6 +70,12 @@ Summary -- Release highlights
New Features
============
+Dictionary Merge & Update Operators
+-----------------------------------
+
+Merge (``|``) and update (``|=``) operators have been added to the built-in
+:class:`dict` class. See :pep:`584` for a full description.
+(Contributed by Brandt Bucher in :issue:`36144`.)
Other Language Changes
More information about the Python-checkins
mailing list