Weak key, strong value immutable registry data structure
Project description
Overview
Registtro provides a weak key/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._core.RegistryEvolver object at ...>
>>> evolver.update({entry_c: 30})
<registtro._core.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-0.1.1.tar.gz
(5.3 kB
view hashes)
Built Distribution
Close
Hashes for registtro-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5288dae8d77950066a2d9abbd936294987cd792a4fb5931bc12adda14df89ca |
|
MD5 | accd52bf224cb7fd504ec46791731048 |
|
BLAKE2b-256 | 302b4c0ec571d3188152e80164f3b333e990ac2519d0fe578883f93ab5dbe07f |