From eeb1cd7acf9bab6396451c055d789e19aa80a504 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 30 Jun 2026 00:36:03 +0300 Subject: [PATCH 1/2] gh-152636: Add a note that `frozendict` is preferable than `MappingProxytype` --- Doc/library/types.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/library/types.rst b/Doc/library/types.rst index 38a77119769d72..b2f98d1138e619 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -390,6 +390,13 @@ Standard names are defined for the following types: signifying (respectively) the types of the underlying mapping's keys and values. + .. warning:: + + ``MappingProxyType`` can expose its internal mapping + in some rare cases on some versions of Python. + Starting from Python 3.15 it is recommeneded + to use truly immutable :class:`frozendict` instead. + .. versionadded:: 3.3 .. versionchanged:: 3.9 From abd4665b44342ea0978d6a2f154258b1cfe2439e Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 30 Jun 2026 17:56:51 +0300 Subject: [PATCH 2/2] Use Raymonds wording for the doc --- Doc/library/types.rst | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Doc/library/types.rst b/Doc/library/types.rst index b2f98d1138e619..82c69e40e7e65b 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -390,12 +390,18 @@ Standard names are defined for the following types: signifying (respectively) the types of the underlying mapping's keys and values. - .. warning:: + .. note:: - ``MappingProxyType`` can expose its internal mapping - in some rare cases on some versions of Python. - Starting from Python 3.15 it is recommeneded - to use truly immutable :class:`frozendict` instead. + 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 mapping in some rare cases. + + While ``frozendict`` is a concrete container type + that actually holds data that cannot be changed in any way. .. versionadded:: 3.3