Skip to content

bpo-36144: Document PEP 584. #18659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
6 changes: 6 additions & 0 deletions Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down