@@ -5305,8 +5305,8 @@ frozenset, a temporary one is created from *elem*.
53055305
53065306.. _typesmapping :
53075307
5308- Mapping Types --- :class: `dict `
5309- ===============================
5308+ Mapping types --- :class: `! dict`, :class: ` !frozendict `
5309+ ======================================================
53105310
53115311.. index ::
53125312 pair: object; mapping
@@ -5317,8 +5317,9 @@ Mapping Types --- :class:`dict`
53175317 pair: built-in function; len
53185318
53195319A :term: `mapping ` object maps :term: `hashable ` values to arbitrary objects.
5320- Mappings are mutable objects. There is currently only one standard mapping
5321- type, the :dfn: `dictionary `. (For other containers see the built-in
5320+ There are currently two standard mapping types, the :dfn: `dictionary ` and
5321+ :class: `frozendict `.
5322+ (For other containers see the built-in
53225323:class: `list `, :class: `set `, and :class: `tuple ` classes, and the
53235324:mod: `collections ` module.)
53245325
@@ -5588,10 +5589,9 @@ can be used interchangeably to index the same dictionary entry.
55885589 Dictionaries are now reversible.
55895590
55905591
5591- .. seealso ::
5592- :class: `types.MappingProxyType ` can be used to create a read-only view
5593- of a :class: `dict `.
5594-
5592+ .. seealso ::
5593+ :class: `types.MappingProxyType ` can be used to create a read-only view
5594+ of a :class: `dict `.
55955595
55965596.. _thread-safety-dict :
55975597
@@ -5839,6 +5839,41 @@ An example of dictionary view usage::
58395839 500
58405840
58415841
5842+ Frozen dictionaries
5843+ -------------------
5844+
5845+ .. class :: frozendict(**kwargs)
5846+ frozendict(mapping, /, **kwargs)
5847+ frozendict(iterable, /, **kwargs)
5848+
5849+ Return a new frozen dictionary initialized from an optional positional
5850+ argument and a possibly empty set of keyword arguments.
5851+
5852+ A :class: `!frozendict ` has a similar API to the :class: `dict ` API, with the
5853+ following differences:
5854+
5855+ * :class: `!dict ` has more methods than :class: `!frozendict `:
5856+
5857+ * :meth: `!__delitem__ `
5858+ * :meth: `!__setitem__ `
5859+ * :meth: `~dict.clear `
5860+ * :meth: `~dict.pop `
5861+ * :meth: `~dict.popitem `
5862+ * :meth: `~dict.setdefault `
5863+ * :meth: `~dict.update `
5864+
5865+ * A :class: `!frozendict ` can be hashed with ``hash(frozendict) `` if all keys and
5866+ values can be hashed.
5867+
5868+ * ``frozendict |= other `` does not modify the :class: `!frozendict ` in-place but
5869+ creates a new frozen dictionary.
5870+
5871+ :class: `!frozendict ` is not a :class: `!dict ` subclass but inherits directly
5872+ from ``object ``.
5873+
5874+ .. versionadded :: next
5875+
5876+
58425877.. _typecontextmanager :
58435878
58445879Context Manager Types
@@ -6062,6 +6097,7 @@ list is non-exhaustive.
60626097* :class: `list `
60636098* :class: `dict `
60646099* :class: `set `
6100+ * :class: `frozendict `
60656101* :class: `frozenset `
60666102* :class: `type `
60676103* :class: `asyncio.Future `
0 commit comments