Skip to content
Closed
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
12 changes: 12 additions & 0 deletions Doc/library/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,18 @@ Standard names are defined for the following types:
signifying (respectively) the types of the underlying mapping's keys and
values.

.. note::

There are important differences between ``MappingProxyType``
and :class:`frozendict`.

``MappingProxyType`` is a wrapper around a mapping that renders
the mapping immutable to the viewer of the proxy
without affecting the underlying container.
``MappingProxyType`` can expose its internal mutable mapping in some rare cases.

On the other hand, ``frozendict`` is a concrete immutable mapping.

@picnixz picnixz Jul 5, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK both MappingProxyType and frozendict are (immutable) mappings if we consider collections.abc.Mapping. So... I don't know whether there is really a need for that note in the end. "concrete immutable mapping" applies to both of them. I'm sorry for being nitpicky though but I agree with Inada here that this note could be more confusing depending on who reads it.

We already say

   Read-only proxy of a mapping. It provides a dynamic view on the mapping's
   entries, which means that when the mapping changes, the view reflects these
   changes.

I would just say (if I were to change the docs, but that's not even sure)

   Read-only proxy of a mapping. It provides a dynamic view on the mapping's
   entries, which means that when the mapping changes, the view reflects these
   changes.

   Use :class:`frozendict` if you want an immutable shallow copy of a mapping.


.. versionadded:: 3.3

.. versionchanged:: 3.9
Expand Down
Loading