Skip to content

Commit d0ca9bd

Browse files
authored
bpo-36144: Document PEP 584 (pythonGH-18659)
1 parent 6aa1f1e commit d0ca9bd

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Doc/library/stdtypes.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4392,6 +4392,22 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
43924392
>>> d.values() == d.values()
43934393
False
43944394

4395+
.. describe:: d | other
4396+
4397+
Create a new dictionary with the merged keys and values of *d* and
4398+
*other*, which must both be dictionaries. The values of *other* take
4399+
priority when *d* and *other* share keys.
4400+
4401+
.. versionadded:: 3.9
4402+
4403+
.. describe:: d |= other
4404+
4405+
Update the dictionary *d* with keys and values from *other*, which may be
4406+
either a :term:`mapping` or an :term:`iterable` of key/value pairs. The
4407+
values of *other* take priority when *d* and *other* share keys.
4408+
4409+
.. versionadded:: 3.9
4410+
43954411
Dictionaries compare equal if and only if they have the same ``(key,
43964412
value)`` pairs (regardless of ordering). Order comparisons ('<', '<=', '>=', '>') raise
43974413
:exc:`TypeError`.

Doc/whatsnew/3.9.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ Summary -- Release highlights
7070
New Features
7171
============
7272

73+
Dictionary Merge & Update Operators
74+
-----------------------------------
75+
76+
Merge (``|``) and update (``|=``) operators have been added to the built-in
77+
:class:`dict` class. See :pep:`584` for a full description.
78+
(Contributed by Brandt Bucher in :issue:`36144`.)
7379

7480

7581
Other Language Changes

0 commit comments

Comments
 (0)