frozenlist
A list-like structure which implements collections.abc.MutableSequence
This package has a good security score with no known vulnerabilities.
Community Reviews
Efficient immutable list with C extension, minimal overhead once frozen
The API is straightforward - standard list operations work until you call .freeze(), after which mutation attempts raise FrozenListError. The C implementation means negligible performance impact in hot paths. Memory usage is comparable to regular lists, and the freeze operation is O(1). Error messages are clear when you attempt mutations on frozen instances.
One quirk: you can't unfreeze a list, so plan your data flow accordingly. There's also no configuration to speak of - it does one thing and does it well. For most applications, you won't use this directly; it'll be pulled in as a transitive dependency. If you do need it directly, documentation is sparse but the API surface is small enough that reading the type stubs tells you everything.
Best for: Building mutable data structures that need to become immutable and shared safely, particularly in async frameworks or configuration objects.
Avoid if: You need to frequently toggle between mutable and immutable states or prefer pure Python dependencies without C extensions.
Simple, focused immutability primitive with minimal security surface
From a security perspective, this is refreshingly minimal. There's no network code, no input parsing complexity, and no cryptographic operations to misconfigure. The C extension implementation is lean and has had few CVEs historically. Error handling is predictable - trying to modify a frozen list raises a clear RuntimeError with no information leakage. The library follows secure-by-default principles by making the immutability contract explicit and enforceable at runtime.
The main limitation is its narrow scope. You're essentially getting immutability enforcement for list-like objects, nothing more. It won't prevent deep mutations of contained objects, so you still need to think about whether nested structures need protection.
Best for: Projects needing explicit, enforceable immutability for shared list-like configuration or state objects.
Avoid if: You need deep immutability guarantees or complex nested data structure protection.
Efficient immutable list primitive with minimal overhead
Day-to-day usage is straightforward: create a FrozenList, manipulate it like a normal list, call freeze() when done, and it becomes immutable. The API is minimal by design - it implements MutableSequence when unfrozen and behaves like a tuple after freezing. Error handling is predictable: attempting mutations after freezing raises a clear RuntimeError. No logging hooks or complex configuration because it's a primitive data structure, not application infrastructure.
The main operational consideration is that this is a building block, not a feature-rich library. It does one thing well: provide an efficient freeze-once list. Performance under load is solid due to the C implementation, though the pure Python fallback exists for compatibility. Breaking changes between versions are rare since the API surface is intentionally tiny.
Best for: Building performance-sensitive libraries that need mutable-then-immutable list semantics, particularly for configuration or header management.
Avoid if: You need standard mutable lists or fully immutable structures from the start - use list or tuple instead.
Sign in to write a review
Sign In