xdol#
A toolkit for working with key-value stores (Extended Data Object Layers), built on dol. Record and replay costly calls, keep one mapping in sync with another, cap a fast store over a slow one, and register plugins in a typed dict.
pip install xdol
Any MutableMapping works as a store: a dict, a folder of files, S3, a database, through dol. That is the difference from functools.lru_cache or joblib.Memory for memoization: the cache lives wherever your store does, and in replay mode a miss raises instead of quietly paying for the call.
from xdol import memoize_calls, update_with_policy
cache = {}
@memoize_calls(store=cache, mode="record")
def square(x):
return x * x
assert square(3) == 9 # computed, and recorded in `cache`
assert square(3) == 9 # replayed from `cache`
assert len(cache) == 1
target = {"a": 1}
update_with_policy(target, {"a": 2, "b": 3}) # default: update keys whose values differ
assert target == {"a": 2, "b": 3}
What is in it#
Module |
What it gives you |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tools that left |
Everything listed is importable from xdol directly.
Persistent memoizer (record/replay)#
Wrap a costly function (a paid API, a slow render) so the first run records its result to disk and every later run replays it:
from xdol import memoize_calls
# A path string becomes a folder store. The default mode is replay-only: a miss raises.
@memoize_calls(store="tests/cassettes", mode="record")
def slow_square(x):
return {"result": x * x}
Stable keys (xdol.keys), text / JSON / binary / paired .json+.bin codecs, any MutableMapping as the store (a folder, S3), spend-safe replay by default. See the persistent memoizer guide.
This documentation as a single file: xdol.md (Markdown, for agents).
built 2026-11-23 11:04 UTC from e8a01c8 (master) · xdol 0.1.44 · about this build