Registry#
Registry exposes genogrove’s registry<std::string, void, json_value> — a
process-wide singleton mapping a string key to any JSON-serializable payload. See
the User Guide for usage and the two intern
forms.
- class pygenogrove.Registry#
Bases:
pybind11_objectA process-wide singleton that interns values into small, stable integer ids (deduplicated). Access the single instance with instance().
Global state — use reset() (or clear()) to wipe it, e.g. between tests.
- clear(self: pygenogrove.Registry) None#
Remove all interned data; ids restart from 0 afterward.
- contains(self: pygenogrove.Registry, id: int) bool#
Whether id refers to a valid entry.
- static deserialize(path: str) pygenogrove.Registry#
Load entries from a file written with serialize() INTO the singleton (replacing its current data) and return it.
- empty(self: pygenogrove.Registry) bool#
Whether the registry has no entries.
- find(self: pygenogrove.Registry, key: str) int | None#
Return the id for key if interned, otherwise None. Does not insert.
- get(self: pygenogrove.Registry, id: int) object#
Return the payload for id. Raises IndexError if id is invalid.
- static instance() pygenogrove.Registry#
Return the process-wide singleton instance.
- intern(*args, **kwargs)#
Overloaded function.
intern(self: pygenogrove.Registry, key: str, payload: object) -> int
Intern key -> payload and return key’s stable id. First write wins: re-interning an existing key keeps its original payload.
intern(self: pygenogrove.Registry, value: str) -> int
Intern a string as both key and payload and return its stable id. Idempotent (deduplicated); get(id) returns the string back. Convenience for plain string interning — use intern(key, payload) to attach a distinct JSON payload.
- null_id = 4294967295#
- static reset() None#
Clear the singleton (convenience for e.g. test isolation; equivalent to instance().clear()).
- serialize(self: pygenogrove.Registry, path: str) None#
Serialize the registry’s (key, payload) entries to a binary file.
- size(self: pygenogrove.Registry) int#
Number of interned entries.