With the release of Python 3.15 Alpha 6, PEP 814 has officially landed, introducing the much-anticipated `frozendict` to the built-in namespace. This provides developers with a highly performant, natively immutable dictionary type.
Unlike `MappingProxyType`, which merely acts as a read-only view over a mutable dictionary, `frozendict` is fundamentally immutable at the C-struct level. Once instantiated, its internal hash table cannot be resized or modified. This static guarantee allows the Python interpreter to pre-calculate and cache the hash of the dictionary itself.
Because `frozendict` is hashable, it can now be safely used as a key within other dictionaries or stored within sets. This is profoundly useful for memoization, abstract syntax tree (AST) caching, and defining complex, immutable configuration states in concurrent applications.
Under the hood, `frozendict` utilizes a densely packed memory layout, eliminating the overhead associated with pre-allocated spare capacity required by standard mutable `dict`s. Benchmarks show a 14% reduction in memory footprint and roughly a 22% increase in read performance due to optimized CPU cache locality.