Module

_internal.invoke_plan

Compiled handler invocation plan — moves per-request reflection out of hot path.

At freeze time we inspect each route handler once and produce an InvokePlan that describes how to build kwargs. The handler uses this plan instead of calling inspect.signature() on every request.

Classes

ParamSpec 3
Spec for one handler parameter — where to get its value.

Spec for one handler parameter — where to get its value.

Attributes

Name Type Description
name str
source ParamSource
annotation type[Any] | None
InvokePlan 6
Precomputed handler invocation plan. Built once at freeze time from handler signature and provider…

Precomputed handler invocation plan.

Built once at freeze time from handler signature and providers. Used by handler to build kwargs without inspect.signature per request.

Attributes

Name Type Description
params tuple[ParamSpec, ...]
has_extract_param bool
is_async bool
inline_sync bool
sync_eligible bool
response_content_type_bytes bytes | None

Functions

compile_invoke_plan 4 InvokePlan
Inspect handler signature once and produce an InvokePlan. Path params take pri…
def compile_invoke_plan(handler: Callable[..., Any], providers: dict[type, Callable[..., Any]] | None = None, *, path_param_names: frozenset[str] | None = None, inline: bool = False) -> InvokePlan

Inspect handler signature once and produce an InvokePlan.

Path params take priority over providers when a param name appears in both.

Parameters
Name Type Description
handler Callable[..., Any]
providers dict[type, Callable[..., Any]] | None Default:None
path_param_names frozenset[str] | None Default:None
inline bool Default:False
Returns
InvokePlan