Accretive data structures.
Project description
🔒 A Python library package which provides accretive data structures - collections which can grow but never shrink.
Key Features ⭐
📖 Accretive Dictionary: Like a regular dict, but entries cannot be modified or removed once added. Also has variants with defaults and validation.
🗃️ Accretive Namespace: Similar to SimpleNamespace, but attributes become immutable after assignment.
🧱 Additional Types: Classes (including abstract base classes), modules, and objects with accretive behavior.
🏗️ Flexible Initialization: Support for unprotected attributes during initialization; useful for compatibility with class decorators, such as dataclasses.
Examples 💡
Accretive Namespace 🗃️
An accretive 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 accretive import Namespace >>> ns = Namespace( apples = 12, bananas = 6 ) >>> ns.cherries = 42 # ✅ Allows new attributes. >>> ns.apples = 14 # ❌ Attempted reassignment raises error. Traceback (most recent call last): ... accretive.exceptions.AttributeImmutabilityError: Cannot reassign or delete existing attribute 'apples'. >>> del ns.apples # ❌ Attempted deletion raises error. Traceback (most recent call last): ... accretive.exceptions.AttributeImmutabilityError: Cannot reassign or delete existing attribute 'apples'. >>> ns accretive.namespaces.Namespace( apples = 12, bananas = 6, cherries = 42 )
Accretive Dictionary 📖
An accretive 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 accretive import Dictionary >>> dct = Dictionary( apples = 12, bananas = 6 ) >>> dct[ 'cherries' ] = 42 # ✅ Allows new entries. >>> dct.update( blueberries = 96, strawberries = 24 ) accretive.dictionaries.Dictionary( {'apples': 12, 'bananas': 6, 'cherries': 42, 'blueberries': 96, 'strawberries': 24} ) >>> dct[ 'bananas' ] = 11 # ❌ Attempted alteration raises error. Traceback (most recent call last): ... accretive.exceptions.EntryImmutabilityError: Cannot alter or remove existing entry for 'bananas'. >>> del dct[ 'bananas' ] # ❌ Attempted removal raises error. Traceback (most recent call last): ... accretive.exceptions.EntryImmutabilityError: Cannot alter or remove existing entry for 'bananas'. >>> dct accretive.dictionaries.Dictionary( {'apples': 12, 'bananas': 6, 'cherries': 42, 'blueberries': 96, 'strawberries': 24} )
Use Cases 🎯
📝 Configuration Registries: Registries which can accumulate entries but never remove them, thereby guaranteeing sticky state.
🔌 Plugin Systems: Register extensions which are then guaranteed to be available from the time of registration to the end of the process.
🔒 Immutable Collections: Many scenarios requiring grow-only collections with immutability guarantees.
Installation 📦
pip install accretive
More Flair
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file accretive-2.1rc0.tar.gz
.
File metadata
- Download URL: accretive-2.1rc0.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fa0e925c614f7d062d5ab9364978eaf617f1e9204bc85e6fa3cd615cc4c519a |
|
MD5 | f1c24b309a8de9a6e74935f098e9fc0f |
|
BLAKE2b-256 | 8fd4d6b61ac79f087ec464f23d999d36ea6ffb2f557ec43ce2c12a1e14d6c242 |
Provenance
The following attestation bundles were made for accretive-2.1rc0.tar.gz
:
Publisher:
releaser.yaml
on emcd/python-accretive
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
accretive-2.1rc0.tar.gz
- Subject digest:
9fa0e925c614f7d062d5ab9364978eaf617f1e9204bc85e6fa3cd615cc4c519a
- Sigstore transparency entry: 150040067
- Sigstore integration time:
- Predicate type:
File details
Details for the file accretive-2.1rc0-py3-none-any.whl
.
File metadata
- Download URL: accretive-2.1rc0-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 815193a9ac03904b0a69adcb56b9ed30e97320a03540b60cbbd9b545e63335df |
|
MD5 | f7ee9aa6abfc450fdb718ea8d9b3600a |
|
BLAKE2b-256 | 1590954455fa9810240d3de24c66dfee1b7684aebf4b6c6248061ae04204090d |
Provenance
The following attestation bundles were made for accretive-2.1rc0-py3-none-any.whl
:
Publisher:
releaser.yaml
on emcd/python-accretive
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
accretive-2.1rc0-py3-none-any.whl
- Subject digest:
815193a9ac03904b0a69adcb56b9ed30e97320a03540b60cbbd9b545e63335df
- Sigstore transparency entry: 150040068
- Sigstore integration time:
- Predicate type: