Skip to content

Generated by sema doc from stdlib/sema/cache.sema. Import with from std.cache import …. For a narrative introduction see std.cache.

std.cache — memoization (design ③).

memoize is a decorator: apply @memoize to any function to cache its result by (callee, arguments) for the current run, over the memory store. Users can write variants (TTL, namespacing) as ordinary decorators. memoize_disk persists across runs under .sema/cache/ (see below).

def memoize(fn, args) -> any !{memory.read, memory.write}

Parameters

nametype
fnany
argsany

Returns any

Effects !{memory.read, memory.write}

def memoize_disk(fn, args) -> any !{fs.read, fs.write}

Parameters

nametype
fnany
argsany

Returns any

Effects !{fs.read, fs.write}