Weak entry, strong value immutable registry data structure
Project description
Overview
Registtro provides a weak entry, strong value immutable registry data structure. Think of it as an immutable WeakKeyDictionary.
Example
>>> from registtro import Registry
>>> class Entry:
... pass
...
>>> # Initialize registry with 2 entries.
>>> entry_a = Entry()
>>> entry_b = Entry()
>>> registry = Registry({entry_a: 1, entry_b: 2})
>>> registry.query(entry_a)
1
>>> # Update a value and add a new entry, retrieve new registry (immutable).
>>> entry_c = Entry()
>>> registry = registry.update({entry_a: 10, entry_c: 3})
>>> registry.query(entry_a)
10
>>> registry.query(entry_c)
3
>>> # Get evolver and perform updates on it (mutable).
>>> evolver = registry.get_evolver()
>>> evolver.update({entry_b: 20})
<registtro._registry.RegistryEvolver object at ...>
>>> evolver.update({entry_c: 30})
<registtro._registry.RegistryEvolver object at ...>
>>> evolver.query(entry_c)
30
>>> # Freeze evolver into a registry (immutable).
>>> registry = evolver.get_registry()
>>> registry.query(entry_c)
30
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
registtro-1.0.0.tar.gz
(6.2 kB
view hashes)
Built Distribution
Close
Hashes for registtro-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90b34fa2d324649554944a5181c007172ae86ce4ffb894226b6066b46b940dae |
|
MD5 | 22e0f13f53965e53883dda25022372a3 |
|
BLAKE2b-256 | 80c1b049b6661ec02b0141fb1cfc254d930d34fa9d28cd5e60c05875551f4e44 |