Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-141510, PEP 814: Add built-in frozendict type#144757
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
bde43791fb7c5afca2e5b99b291c5e4a2845c0c6f18d4ed14c7706136dfec489101b1ae845b2b3d08f46258b3df09abcf53653eeb5bc207aFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -5305,8 +5305,8 @@ frozenset, a temporary one is created from *elem*. | ||
| .. _typesmapping: | ||
| Mapping Types --- :class:`dict` | ||
| =============================== | ||
| Mapping types --- :class:`!dict`, :class:`!frozendict` | ||
| ====================================================== | ||
| .. index:: | ||
| pair: object; mapping | ||
| @@ -5317,8 +5317,9 @@ Mapping Types --- :class:`dict` | ||
| pair: built-in function; len | ||
| A :term:`mapping` object maps :term:`hashable` values to arbitrary objects. | ||
| Mappings are mutable objects. There is currently only one standard mapping | ||
| type, the :dfn:`dictionary`. (For other containers see the built-in | ||
| There are currently two standard mapping types, the :dfn:`dictionary` and | ||
| :class:`frozendict`. | ||
| (For other containers see the built-in | ||
| :class:`list`, :class:`set`, and :class:`tuple` classes, and the | ||
| :mod:`collections` module.) | ||
| @@ -5588,10 +5589,9 @@ can be used interchangeably to index the same dictionary entry. | ||
| Dictionaries are now reversible. | ||
| .. seealso:: | ||
| :class:`types.MappingProxyType` can be used to create a read-only view | ||
| of a :class:`dict`. | ||
| .. seealso:: | ||
| :class:`types.MappingProxyType` can be used to create a read-only view | ||
| of a :class:`dict`. | ||
| .. _thread-safety-dict: | ||
| @@ -5839,6 +5839,41 @@ An example of dictionary view usage:: | ||
| 500 | ||
| Frozen dictionaries | ||
| ------------------- | ||
| .. class:: frozendict(**kwargs) | ||
| frozendict(mapping, /, **kwargs) | ||
| frozendict(iterable, /, **kwargs) | ||
| Return a new frozen dictionary initialized from an optional positional | ||
| argument and a possibly empty set of keyword arguments. | ||
| A :class:`!frozendict` has a similar API to the :class:`dict` API, with the | ||
| following differences: | ||
| * :class:`!dict` has more methods than :class:`!frozendict`: | ||
vstinner marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| * :meth:`!__delitem__` | ||
| * :meth:`!__setitem__` | ||
| * :meth:`~dict.clear` | ||
| * :meth:`~dict.pop` | ||
| * :meth:`~dict.popitem` | ||
| * :meth:`~dict.setdefault` | ||
| * :meth:`~dict.update` | ||
| * A :class:`!frozendict` can be hashed with ``hash(frozendict)`` if all keys and | ||
| values can be hashed. | ||
| * ``frozendict |= other`` does not modify the :class:`!frozendict` in-place but | ||
| creates a new frozen dictionary. | ||
| :class:`!frozendict` is not a :class:`!dict` subclass but inherits directly | ||
vstinner marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| from ``object``. | ||
| .. versionadded:: next | ||
| .. _typecontextmanager: | ||
| Context Manager Types | ||
| @@ -6062,6 +6097,7 @@ list is non-exhaustive. | ||
| * :class:`list` | ||
| * :class:`dict` | ||
| * :class:`set` | ||
| * :class:`frozendict` | ||
| * :class:`frozenset` | ||
| * :class:`type` | ||
| * :class:`asyncio.Future` | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.