Existing Frozen types/structures in Python

Python already has a bunch of immutable / “frozen-ish” data structures, just not a first-class frozendict (yet). Some are true containers like tuple and frozenset, others are read-only views or “frozen” user-defined records.

Here’s the landscape.


1. Core immutable containers

These are the big ones everyone leans on already:

These are all actual objects that cannot be mutated once created.


2. Less obvious mapping-ish immutables in the stdlib

Even before a frozendict, there is an immutable dict-like thing:

There are also APIs that return immutable mapping-like objects, even if the type is not directly constructible:


3. “Frozen record” types for your own data

These are meant for user-defined structured data, not arbitrary mappings, but they’re still immutable containers of a sort:

These are strongly used as “frozen structs” more than as general purpose containers.


4. Immutable value objects elsewhere in the stdlib

Not containers, but they behave like immutable data types:

These matter when you want functional-style programming or safe sharing across threads.


5. Third-party persistent / functional data structures

For “real” immutable data structures in the functional-programming sense (structural sharing, cheap copies), you’re typically looking at external libraries:

immutables (immutables.Map)

pyrsistent

attrs with frozen=True

These libraries are the spiritual ancestors of a future frozendict in the stdlib: they show the ergonomics and performance characteristics people care about.


6. “Frozen dict” vs what exists now

So conceptually:

Right now, if I want an honest-to-goodness immutable dict-like structure without third party dependencies, the closest is:


7. Mental model cheat sheet

When you think “immutable / frozen” in Python, it’s useful to sort things into:

A frozendict would just complete the “primitive immutable containers” story, which is why so many people are excited about it.