Live Feed/Python/Fact Record
Python logo
Python
api 96% Confidence Gate July 15, 2026

PEP 839: PyFrozenSetWriter and PyFrozenDictWriter C API

The Python C API introduces PyFrozenSetWriter and PyFrozenDictWriter to facilitate the creation of immutable collections. These builders allow for the construction of frozenset and frozendict objects in a single pass without intermediate mutable states.

Verified State Diff

Comparison Mode:
- Previous State
Creation of frozenset and frozendict required the instantiation of mutable intermediate objects, increasing memory overhead and complexity.
+ Verified New State
Direct, single-pass construction of frozenset and frozendict objects via PyFrozenSetWriter and PyFrozenDictWriter C APIs.

Impact & Verification Analysis

WHO IS AFFECTED

CPython core developers, extension module authors, and performance-critical library maintainers.

WHY IT MATTERS

Improves memory efficiency and performance for immutable data structure creation while enforcing stricter object immutability patterns at the C level.

Full Fact Overview

PEP 839 extends the builder pattern established by PEP 782 (PyBytesWriter) to the Python C API for immutable types. By utilizing these new writer interfaces, developers can populate collections directly into their final immutable form. This architectural shift eliminates the overhead and potential safety risks associated with creating a mutable intermediate object (like a standard dict or set) before converting it to its frozen counterpart, aligning with the upcoming introduction of frozendict as defined in PEP 814.

Multi-Source Evidence Chain (1)

PEP 839: PyFrozenSetWriter and PyFrozenDictWriter C APIPython
TRACKED ENTITY
Explore all historical Python changes
View Python Hub ➔