frozenlist

A list-like Python type that can be frozen at runtime to guard shared state from further mutation.

Library
PyPI
v1.8.0
127stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
81/100Excellent
Development Activity96
Maintenance72
Community76
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture85
Code Quality92
Innovation62
Learning Curve85

frozenlist provides FrozenList, a collections.abc.MutableSequence implementation that behaves like an ordinary Python list until .freeze() is called, after which any further mutation raises RuntimeError. It ships as part of the aio-libs project and is used internally by aiohttp and its ecosystem to lock down configuration and header collections once application setup has finished, preventing accidental mutation of shared state deep in a request-handling call stack.

The package includes two interchangeable implementations: a pure-Python reference version and a Cython/C++ extension compiled for CPython and free-threaded builds, selected automatically at import time (or forced to the pure-Python path via the FROZENLIST_NO_EXTENSIONS environment variable). Both expose the exact same interface, including hashing once frozen, so FrozenList instances can be used as dict keys or set members after being locked.

What You Get

  • A FrozenList class implementing the complete collections.abc.MutableSequence interface (indexing, slicing, insert, append, extend, reverse, pop, etc.)
  • A .freeze() method and .frozen property that toggle and expose the list’s mutability state at runtime
  • Hashability once frozen, so a locked FrozenList can be used as a dict key or set member
  • A high-performance Cython/C++ extension backend with an atomic frozen flag for free-threaded (no-GIL) Python builds, plus a pure-Python fallback selectable via FROZENLIST_NO_EXTENSIONS
  • Correct __copy__ and __deepcopy__ behavior that preserves the frozen state of the copy

Common Use Cases

  • Freezing a collection of HTTP headers or middleware after an aiohttp application finishes setup, so later code cannot silently mutate it
  • Building a list incrementally during configuration/init and then locking it before handing it to concurrent request handlers
  • Using a completed, frozen list as a hashable key in a cache or lookup dict
  • Any general Python code that wants list semantics during a build-up phase and immutability guarantees afterward

Under The Hood

Architecture frozenlist ships two parallel implementations of the same public interface behind a single import: a pure-Python FrozenList in frozenlist/__init__.py and a Cython/C++ extension in frozenlist/_frozenlist.pyx, with the extension transparently substituted for the Python class at import time unless FROZENLIST_NO_EXTENSIONS is set. Both implementations register with collections.abc.MutableSequence and route every mutating method (__setitem__, __delitem__, insert, append, extend, remove, clear, pop, reverse, __iadd__) through a shared frozen-state guard that raises RuntimeError once .freeze() has been called, so behavior stays identical regardless of which backend is active; the C extension additionally uses atomic<bool> for its frozen flag rather than a plain attribute, making state checks safe under free-threaded (no-GIL) CPython.

Tech Stack The project targets Python 3.10+ and compiles its extension module from Cython source (_frozenlist.pyx, language = c++) via an in-tree PEP 517 build backend (packaging/pep517_backend) layered on setuptools >= 67; wheels are built and tested across platforms with cibuildwheel configured to use uv as its installer/build frontend for fast, reproducible environment provisioning. Code quality tooling includes ruff for import sorting and pyupgrade-style modernization, mypy for static typing, pytest for tests, and towncrier for changelog generation from per-PR news fragments.

Code Quality A single tests/test_frozenlist.py file exercises both backends through a shared FrozenListMixin test base, verifying full MutableSequence protocol conformance, freeze/hash semantics, __class_getitem__ generic subscripting, and both shallow and deep copy behavior with frozen-state preservation and circular-reference handling. CI runs this suite across the supported CPython version matrix plus PyPy, with mypy and ruff enforced via pre-commit hooks and coverage tracked through Codecov, giving the project a typed, tested, and continuously linted baseline for a codebase this small.

What Makes It Unique frozenlist isn’t conceptually novel — freezable/immutable list wrappers are a well-known pattern — but its dual pure-Python/Cython implementation, switchable at runtime via an environment variable, and its use of an atomic frozen flag specifically to stay correct under free-threaded Python builds, are deliberate, forward-looking engineering choices for what is otherwise a narrowly scoped utility that exists mainly to give the aiohttp ecosystem a safe way to lock down shared collections after setup.

Used by 7 apps in this directory

Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,969

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python100%
Updated today
Python
67%
Apache 2.0

GPT Researcher

Productivity · AI Assistants

29,203

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
91
Repo Health
91
Technical
64
Dependency
Built with
Python67%
TypeScript20%
Updated 3 days ago
TypeScript
91%
Apache 2.0

Helicone

Monitoring · AI Development · Analytics

6,115

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
65
Repo Health
81
Technical
66
Dependency
Built with
TypeScript91%
Updated 4 days ago
Python
84%
Apache 2.0

knowhere

AI Development · Developer Tools

2,752

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
83
Repo Health
75
Technical
69
Dependency
Built with
Python84%
HTML15%
Updated today
Python
61%
Apache 2.0

marimo

Developer Tools · Data Engineering

22,545

A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.

View details
89
Repo Health
91
Technical
65
Dependency
Built with
Python61%
TypeScript37%
Updated yesterday
Rust
63%
MIT

PostgresML

Databases · AI Development

6,821

Run ML training and LLM inference natively inside PostgreSQL with GPU acceleration — no data movement required.

View details
51
Repo Health
76
Technical
64
Dependency
Built with
Rust63%
JavaScript11%
Updated 1 years ago
Python
94%
Apache 2.0

SWIRL

Search · Databases · Data Engineering

3,042

Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.

View details
73
Repo Health
83
Technical
65
Dependency
Built with
Python94%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search