pure
pure
#
pure_function — memoize a pure function over CGType values.
PureFunction
#
A memoized pure function: a plain synchronous call.
Source code in capturegraph-lib/capturegraph/recipes/calls/pure.py
__call__(*args, **kwargs)
#
Serve the call from cache, or run the body and seal the result.
A Missing argument makes the result Missing without running or
caching anything, so absence chains through a recipe as it does
through attribute access.
Source code in capturegraph-lib/capturegraph/recipes/calls/pure.py
__init__(func, identity)
#
Wrap func; see pure_function for the parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[P, T]
|
The pure body to memoize. |
required |
identity
|
str | None
|
An explicit versioned identity, or |
required |
Source code in capturegraph-lib/capturegraph/recipes/calls/pure.py
key(*args, **kwargs)
#
The cache key of this function applied to these arguments, defaults applied.
Raises:
| Type | Description |
|---|---|
UnhashableArgumentError
|
If an argument has no canonical content hash. |
Source code in capturegraph-lib/capturegraph/recipes/calls/pure.py
pure_function(identity=None)
#
Memoize a pure function over CGType values in the scratch cache.
Invalidation contract: a versioned identity ("name/1") means you
own invalidation — editing the body without bumping the version keeps
serving the stale cache, deliberately; bump to "name/2" to invalidate.
The bare form digests the compiled body instead, so any edit invalidates
automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identity
|
Callable[P, T] | str | None
|
A versioned identity string, |
None
|
Returns:
| Type | Description |
|---|---|
PureFunction[P, T] | Callable[[Callable[P, T]], PureFunction[P, T]]
|
The memoized function, or a decorator producing one. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an explicit identity is not of the |
TypeError
|
If the return annotation is missing or not CGType-typed. |