FrozenList
FrozenList is a Python library providing a list-like structure that implements collections.abc.MutableSequence. The list remains mutable until the freeze() method is called, after which any modifications raise a RuntimeError. The current version is 1.8.0, released in October 2025, with a release cadence of approximately one to two updates per year.
Warnings
- breaking Dropped support for Python 3.7 in version 1.4.0.
- breaking Dropped support for Python 3.6 in version 1.3.0.
- gotcha Attempting to modify a FrozenList after calling freeze() raises a RuntimeError.
- gotcha A FrozenList instance is hashable only when frozen; attempting to hash a non-frozen instance raises a RuntimeError.
Install
-
pip install frozenlist
Imports
- FrozenList
from frozenlist import FrozenList
Quickstart
from frozenlist import FrozenList
# Create a mutable FrozenList
fl = FrozenList([1, 2, 3])
fl.append(4)
print(fl) # Output: [1, 2, 3, 4]
# Freeze the list
fl.freeze()
# Attempting to modify the frozen list raises RuntimeError
try:
fl.append(5)
except RuntimeError as e:
print(e) # Output: Cannot modify frozen list.