merton.cache

Disk-backed memoization for expensive calibration outputs.

Wraps joblib.Memory keyed on input array hashes. Off by default; call enable() to opt in.

Functions

enable(→ None)

Turn on persistent calibration caching.

disable(→ None)

Turn off persistent calibration caching.

is_enabled(→ bool)

clear(→ None)

Drop the entire on-disk cache.

cached(→ F)

Decorator: cache the function's outputs on disk when caching is on.

Module Contents

merton.cache.enable(cache_dir: pathlib.Path | str | None = None) None[source]

Turn on persistent calibration caching.

merton.cache.disable() None[source]

Turn off persistent calibration caching.

merton.cache.is_enabled() bool[source]
merton.cache.clear() None[source]

Drop the entire on-disk cache.

merton.cache.cached(func: F) F[source]

Decorator: cache the function’s outputs on disk when caching is on.

No-op (returns the function unchanged) when caching is disabled, so users pay zero overhead unless they opt in.