diff --git a/peps/pep-0814.rst b/peps/pep-0814.rst index 91ac0b3e649..45648734d0d 100644 --- a/peps/pep-0814.rst +++ b/peps/pep-0814.rst @@ -2,11 +2,12 @@ PEP: 814 Title: Add frozendict built-in type Author: Victor Stinner , Donghee Na Discussions-To: https://discuss.python.org/t/104854 -Status: Draft +Status: Accepted Type: Standards Track Created: 12-Nov-2025 Python-Version: 3.15 Post-History: `13-Nov-2025 `__ +Resolution: `11-Feb-2026 `__ Abstract @@ -43,10 +44,6 @@ desirable: * Using an immutable mapping as a function parameter's default value avoids the problem of mutable default values. -* Immutable mappings can be used to safely share dictionaries across - thread and asynchronous task boundaries. The immutability makes it - easier to reason about threads and asynchronous tasks. - There are already third-party ``frozendict`` and ``frozenmap`` packages available on PyPI, proving that there is demand for immutable mappings. @@ -221,12 +218,6 @@ Passing a ``frozendict`` to ``PyDict_SetItem()`` or ``PyDict_DelItem()`` fails with ``TypeError``. ``PyDict_Check()`` on a ``frozendict`` is false. -Exposing the C API helps authors of C extensions supporting -``frozendict`` when they need to support thread-safe immutable -containers. It will be important since -:pep:`779` (Criteria for supported status for free-threaded Python) was -accepted, people need this for their migration. - Differences between ``dict`` and ``frozendict`` =============================================== @@ -251,7 +242,8 @@ Possible candidates for ``frozendict`` in the stdlib We have identified several stdlib modules where adopting ``frozendict`` can enhance safety and prevent unintended modifications by design. We also believe that there are additional potential use cases beyond the -ones listed below. +ones listed below. However, this does not mean that we intend to make +these changes without the approval of the respective module maintainers. Note: it remains possible to bind again a variable to a new modified ``frozendict`` or a new mutable ``dict``. @@ -362,15 +354,9 @@ Reference Implementation Thread Safety ============= -Once the ``frozendict`` is created, it is immutable and can be shared -safely between threads without any synchronization. - - -Future Work -=========== - -We are also going to make ``frozendict`` to be more efficient in terms -of memory usage and performance compared to ``dict`` in future. +Once a ``frozendict`` is created, its shallow immutability is guaranteed. +This means it can be safely shared between threads without synchronization, +as long as its values are not modified by other threads. Rejected Ideas