PEP 814, by Victor Stinner and Donghee Na, was accepted on February 11, 2026. Python 3.15 includes frozendict as a built-in. A mapping can prevent its entries from being replaced while a list stored inside it can still change. That distinction matters when building cache keys. PEP 814 and its acceptance record
What frozendict Actually Is
A frozendict preserves insertion order when you iterate. Equality ignores insertion order, as it does for a regular dictionary. You cannot assign a value to a key after construction. To use the mapping as a key in another mapping, all its values must also be hashable. Try both branches under Python 3.15.
options = frozendict({"size": (3, 4), "format": "png"})
reverse = frozendict({"format": "png", "size": (3, 4)})
assert list(options) == ["size", "format"]
assert options == reverse and hash(options) == hash(reverse)
cache = {options: "thumbnail"}
assert cache[reverse] == "thumbnail"
sizes = [3, 4]
shallow = frozendict({"size": sizes})
try:
hash(shallow)
except TypeError as exc:
assert "list" in str(exc)
else:
raise AssertionError("expected a list value to be unhashable")
sizes.append(5)
assert shallow["size"] == [3, 4, 5]
Why It Took Over a Decade
PEP 416 proposed an earlier frozen dictionary and was rejected in 2012. PEP 814 describes how the later proposal handles construction, order-independent hashing and interoperability with Mapping. The new type is available to code running on 3.15. A package that supports earlier Python releases still needs a compatible representation. PEP 416 · Python built-in mapping types
What Changes in Practice
A cache of processed images might key on dimensions and format as shown above. Normalize the dimensions to an immutable tuple at the boundary only if the input’s meaning allows it. A configuration exposed to callers can also use a frozen outer mapping when hashability is irrelevant. Document whether nested values are shared, copied or frozen independently so the caller knows what can change.
Correction, November 25, 2026. This article previously described the PEP as undecided and implied every frozendict could be hashed. The acceptance date, target version and contrasting hash results are now explicit.
Your notes on this article
Your name or initials, note and date stay in this browser profile. Anyone using the profile can read them. Delete a note below or clear this site’s browser data. To reach the editors, report a correction.
No notes saved here