Member-only story
Python 3.15 Has a New Kind of Dict. And It’s Not What I Expected.
Your dictionaries can now be hashable, cacheable, and impossible to accidentally modify. Here are 7 surprisingly useful things that unlocks.
Python dictionaries are everywhere. We use them for configuration, API responses, experiment parameters, lookup tables, and countless other everyday tasks.
They are flexible, convenient, and easy to work with. But sometimes that flexibility becomes a limitation.
What if you want to use an entire dictionary as a key? What if you want to cache a function that accepts a configuration dictionary? Or make sure a function cannot accidentally modify settings shared across your application?
Until recently, these situations required workarounds or additional libraries.
Python 3.15 introduces frozendict, a new built-in immutable dictionary type.
It behaves much like a regular dictionary, with one important difference: once created, its entries cannot be changed.
config = frozendict(batch_size=64, epochs=20)
print(config["batch_size"]) # 64
config["batch_size"] = 128 # TypeErrorThere is no package to install and no special import. frozendict is part of Python itself.








