frigid
🔒 A Python library package which provides immutable data structures - collections which cannot be modified after creation.
Key Features ⭐
📖 Immutable Dictionary: Like a regular dict, but entries cannot be modified or removed. Also has variant for validation on initialization. And provides set operations not found on MappingProxyType.
🗃️ Immutable Namespace: Similar to SimpleNamespace, but attributes are immutable from creation.
🧱 Additional Types: Classes (including abstract base classes), modules, and objects with immutable behavior.
🏗️ Flexible Initialization: Support for unprotected attributes during initialization; useful for compatibility with class decorators, such as dataclasses.
🔓 Flexible Mutability: Support for declaring specific attributes as mutable, enabling selective modification while maintaining immutability for other attributes.
Installation 📦
Method: Install Python Package
Install via uv pip command:
uv pip install frigid
Or, install via pip:
pip install frigid
Note on Immutability 📢
Enforcement of immutability is quite difficult in Python. While this library enforces immutability by default, it can be circumvented by anyone who has intermediate knowledge of Python machinery and who is determined to circumvent the immutability. Use the library in the spirit of making programs safer, but understand that it cannot truly prevent unwanted state tampering.
Examples 💡
Immutable Namespaces 🗃️
An immutable namespace, similar to types.SimpleNamespace, is available. This namespace can be initialized from multiple iterables and from keyword arguments. (Keyword arguments shown below; see documentation for additional forms of initialization.)
>>> from frigid import Namespace >>> ns = Namespace( apples = 12, bananas = 6 ) >>> ns.cherries = 42 # ❌ Attempted assignment raises error. Traceback (most recent call last): ... frigid.exceptions.AttributeImmutability: Could not assign or delete attribute 'cherries'. >>> del ns.apples # ❌ Attempted deletion raises error. Traceback (most recent call last): ... frigid.exceptions.AttributeImmutability: Could not assign or delete attribute 'apples'. >>> ns frigid.namespaces.Namespace( apples = 12, bananas = 6 )
Immutable Dictionaries 📖
An immutable dictionary, similar to dict, is available. This dictionary can be initialized from multiple iterables and from keyword arguments. (Keyword arguments shown below; see documentation for additional forms of initialization.)
>>> from frigid import Dictionary
>>> dct = Dictionary( apples = 12, bananas = 6)
>>> dct['cherries'] = 42 # ❌ Attempted assignment raises error.
Traceback (most recent call last):
...
frigid.exceptions.EntryImmutability: Cannot assign entry for 'cherries'.
>>> del dct['bananas'] # ❌ Attempted removal raises error.
Traceback (most recent call last):
...
frigid.exceptions.EntryImmutability: Cannot delete entry for 'bananas'.
>>> dct
frigid.dictionaries.Dictionary( {'apples': 12, 'bananas': 6} )
Immutable Objects 🧱
The with_standard_behaviors decorator can be applied to any class to make its instances fully immutable after initialization.
>>> from frigid import with_standard_behaviors >>> @with_standard_behaviors( ) ... class Config: ... def __init__( self, debug = False ): ... self.debug = debug ... >>> config = Config( debug = True ) >>> config.verbose = True # ❌ Attempted addition raises error Traceback (most recent call last): ... frigid.exceptions.AttributeImmutability: Could not assign or delete attribute 'verbose'. >>> config.debug = False # ❌ Attempted reassignment raises error Traceback (most recent call last): ... frigid.exceptions.AttributeImmutability: Could not assign or delete attribute 'debug'.
Use Cases 🎯
🔒 Configuration Objects: Objects which must maintain consistent state throughout program execution.
📊 Value Objects: Objects which represent values and should be immutable, like numbers or strings.
🧱 Immutable Collections: Many scenarios requiring collections with complete immutability guarantees.
Contribution 🤝
Contribution to this project is welcome! However, it must follow the code of conduct for the project.
Please file bug reports and feature requests in the issue tracker or submit pull requests to improve the source code or documentation.
For development guidance and standards, please see the development guide.
Additional Indicia
Release files for frigid 4.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| frigid-4.3.tar.gz | 22.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| frigid-4.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.9 kB
Release files / frigid-4.3.tar.gz
| Download URL | frigid-4.3.tar.gz |
|---|---|
| Size | 22.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
709974fbb7868031f38e978321370c0eaa54bfbaeb45e92dc0e81ad3cfd5f6d8
|
|
BLAKE2b-256 checksum How to use checksums |
80b0db6adb3dcbe38d45cfa9e32d403334e2043cea68817c157160fb1eaadc58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency logRelease files / frigid-4.3-py3-none-any.whl
| Download URL | frigid-4.3-py3-none-any.whl |
|---|---|
| Size | 30.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed9e8005502a636d0794779d3a42b5eb3c6c4383d2b22b0bd04d7b062b3289bc
|
|
BLAKE2b-256 checksum How to use checksums |
73ae4918fb35cde394ca5039095591a5d0364df046ee51422ce64c5b63fbc08a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency log