zoomy_core.model.derivation.derivation_cache

zoomy_core.model.derivation.derivation_cache#

Function-level derivation cache: memoizes expensive derivation stages on (function source, argument content). In-memory by default with an optional pickle tier on disk; decorate leaf stages, not the orchestrator.

Module Contents#

Classes#

CacheStats

Hit, miss and wrapped-body call counters of one decorated function.

Functions#

derivation_cache

Memoize a derivation stage, keyed on function source and argument content; usable bare or with arguments.

clear_derivation_cache

Clear all entries, or those of one decorated function.

cache_size

Return the total number of cached entries.

Data#

API#

zoomy_core.model.derivation.derivation_cache.logger#

‘getLogger(…)’

class zoomy_core.model.derivation.derivation_cache.CacheStats#

Hit, miss and wrapped-body call counters of one decorated function.

Initialization

Zero all counters.

zoomy_core.model.derivation.derivation_cache.derivation_cache(fn=None, *, version=0, verify=False, persist=False)#

Memoize a derivation stage, keyed on function source and argument content; usable bare or with arguments.

Args

  • version: Bump to invalidate the entries without editing the body.

  • verify: On a hit re-run the body and assert an identical srepr (test aid).

  • persist: Add a cross-session pickle tier; unpicklable results stay in memory.

Returns

The wrapped function with .stats, .cache_clear() and .wrapped.

zoomy_core.model.derivation.derivation_cache.clear_derivation_cache(fn=None)#

Clear all entries, or those of one decorated function.

zoomy_core.model.derivation.derivation_cache.cache_size() → int#

Return the total number of cached entries.