fleche.call
Attributes
Classes
Type wrapper to mark a function argument as ignored for caching. |
|
Type wrapper to mark a function argument as required for caching. |
|
All static per-function metadata, cached once per callable. |
|
Represents a function call, capturing its name, arguments, and keyword arguments. |
|
A Call where arguments and result are |
|
Functions
|
Thin wrapper around |
Module Contents
- class fleche.call.Ignored[source]
Type wrapper to mark a function argument as ignored for caching.
Can be used as a type hint:
arg: fleche.Ignoredorarg: fleche.Ignored[int].
- class fleche.call.Required[source]
Type wrapper to mark a function argument as required for caching.
Arguments marked as required must be explicitly provided by the caller as keyword arguments (i.e. not via their default value) for the result to be cached. This is useful for arguments like random seeds or iteration counts, where using the default value might lead to non-deterministic or otherwise undesirable caching behavior.
This is mainly useful when wrapping third-party functions where you do not control the default arguments.
Can be used as a type hint:
arg: fleche.Requiredorarg: fleche.Required[int].
- class fleche.call.FunctionProfile[source]
All static per-function metadata, cached once per callable.
- code_digest: fleche.digest.Digest | None[source]
- classmethod of(func) FunctionProfile[source]
Compute a
FunctionProfilefor func without caching.
- fleche.call.bind(func, args, kwargs, apply_defaults=False, partial=False)[source]
Thin wrapper around
inspect.Signature.bind()/bind_partial().- Parameters:
func – The callable whose signature to bind against.
args – Positional arguments.
kwargs – Keyword arguments.
apply_defaults – If
True, fill in default values for parameters that were not explicitly supplied.partial – If
True, usebind_partial(), which allows required arguments to be omitted (treated as wildcards).
- Returns:
inspect.BoundArguments.arguments— anOrderedDictcontaining the supplied (and, when requested, defaulted) values.
- class fleche.call.Call[source]
Represents a function call, capturing its name, arguments, and keyword arguments.
module and version can be optionally set to be included in the hash of the call. version should be a plain integer and monotonically increase. Each different version will completely change the hash of the call, invalidating previously cached results.
- to_lookup_key() fleche.digest.Digest[source]
- _to_digested(save_fn: Callable[[Any], fleche.digest.Digest]) DigestedCall[source]
Generic conversion to DigestedCall using save_fn to handle each value.
- stash(values) DigestedCall[source]
Save arguments and result into values, returning a
DigestedCall.Result save errors propagate to the caller. Argument save errors fall back to a digest-only reference (the value is hashed but not stored).
- Parameters:
values – A
ValueStorageinstance to persist values into.- Returns:
A
DigestedCallwith all argument values and the result replaced by theirDigestkeys.
See also
digest()for a variant that does not write to storage.
- digest() DigestedCall[source]
Digest arguments and result without saving to storage, returning a
DigestedCall.Equivalent to
stash()but usesdigest()instead ofvalues.save, so no data is written anywhere.
- class fleche.call.DigestedCall[source]
A Call where arguments and result are
Digestpointers into a value store.Produced by
Call.stash()orCall.digest(); represents a call whose values have been replaced by their content-addressed keys.- arguments: dict[str, fleche.digest.Digest][source]
- result: fleche.digest.Digest | None = None[source]
- to_lookup_key() fleche.digest.Digest[source]
- class fleche.call.LazyCall[source]
-
- detach() DigestedCall[source]
Return the cache-free
DigestedCallshadow of thisLazyCall.The inverse of
DigestedCall.fetch(): strips the_cachereference so the result can cross process boundaries (e.g. over the wire infleche.remote) without carrying a live cache pointer.
- class fleche.call.QueryCall[source]
-
- code_digest: fleche.digest.Digest | None = None[source]
- matches(other: Call | LazyCall | DigestedCall) bool[source]
Check if this call matches another call, treating None as a wildcard in this object.