Skip to content
Merged
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
28 changes: 7 additions & 21 deletions peps/pep-0814.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ PEP: 814
Title: Add frozendict built-in type
Author: Victor Stinner <vstinner@python.org>, Donghee Na <donghee.na@python.org>
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 <https://discuss.python.org/t/104854>`__
Resolution: `11-Feb-2026 <https://discuss.python.org/t/pep-814-add-frozendict-built-in-type/104854/121>`__


Abstract
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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``
===============================================
Expand All @@ -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``.
Expand Down Expand Up @@ -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
Expand Down
Loading