FrozenList

1.8.0 · active · verified Sat Mar 28

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

Install

Imports

Quickstart

Demonstrates creating a FrozenList, modifying it, freezing it, and handling attempts to modify it after freezing.

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.

view raw JSON →