Classes
BlockLoweringStrategy
0
▼
How one streaming block variant is produced.
BlockLoweringStrategy
0
▼
How one streaming block variant is produced.
BlockRenderModePlan
2
▼
Lowering strategies for the stream and async-stream block variants.
BlockRenderModePlan
2
▼
Lowering strategies for the stream and async-stream block variants.
Attributes
| Name | Type | Description |
|---|---|---|
stream |
BlockLoweringStrategy
|
— |
async_stream |
BlockLoweringStrategy
|
— |
BlockFunctionVariants
3
▼
The sync, stream, and async-stream functions lowered for one block.
BlockFunctionVariants
3
▼
The sync, stream, and async-stream functions lowered for one block.
Attributes
| Name | Type | Description |
|---|---|---|
sync |
ast.FunctionDef
|
— |
stream |
ast.FunctionDef
|
— |
async_stream |
ast.AsyncFunctionDef
|
— |
_AppendToYield
2
▼
Replace ``_append(expr)`` with ``yield expr`` in Python AST.
Overrides ``generic_visit`` with a co…
_AppendToYield
2
▼
Replace_append(expr) with yield exprin Python AST.
Overridesgeneric_visitwith a copy-on-write strategy: only nodes
whose children actually changed are shallow-copied. Unchanged subtrees
are returned as-is (identity), so the original AST is never mutated.
Methods
visit_Expr
1
ast.Expr
▼
Transform _append(x) expression statements to yield x.
visit_Expr
1
ast.Expr
▼
def visit_Expr(self, node: ast.Expr) -> ast.Expr
Parameters
| Name | Type | Description |
|---|---|---|
node |
— |
Returns
ast.Expr
generic_visit
1
ast.AST
▼
Copy-on-write: only copy nodes whose children changed.
generic_visit
1
ast.AST
▼
def generic_visit(self, node: ast.AST) -> ast.AST
Parameters
| Name | Type | Description |
|---|---|---|
node |
— |
Returns
ast.AST
Functions
plan_block_render_modes
4
BlockRenderModePlan
▼
Choose direct compilation or sync-AST transformation for each variant.
plan_block_render_modes
4
BlockRenderModePlan
▼
def plan_block_render_modes(*, is_region: bool, rebinds_append: bool, template_has_regions: bool, template_has_async: bool) -> BlockRenderModePlan
Parameters
| Name | Type | Description |
|---|---|---|
is_region |
bool |
|
rebinds_append |
bool |
|
template_has_regions |
bool |
|
template_has_async |
bool |
Returns
BlockRenderModePlan
sync_body_to_stream
1
list[ast.stmt]
▼
Transform compiled sync body statements into streaming equivalents.
Walks the …
sync_body_to_stream
1
list[ast.stmt]
▼
def sync_body_to_stream(stmts: list[ast.stmt]) -> list[ast.stmt]
Transform compiled sync body statements into streaming equivalents.
Walks the AST and replaces_append(expr) calls with yield expr.
Uses copy-on-write so the original stmts are never modified — safe to
call repeatedly on the same input.
Parameters
| Name | Type | Description |
|---|---|---|
stmts |
list[ast.stmt] |
Compiled Python AST statements from sync block compilation. |
Returns
list[ast.stmt]
_build_transformed_block_body
3
list[ast.stmt]
▼
Assemble one transformed block body in runtime contract order.
_build_transformed_block_body
3
list[ast.stmt]
▼
def _build_transformed_block_body(*, preamble: list[ast.stmt], cache_assignments: list[ast.stmt], compiled_stmts: list[ast.stmt]) -> list[ast.stmt]
Parameters
| Name | Type | Description |
|---|---|---|
preamble |
list[ast.stmt] |
|
cache_assignments |
list[ast.stmt] |
|
compiled_stmts |
list[ast.stmt] |
Returns
list[ast.stmt]
_block_arguments
0
ast.arguments
▼
Build the shared ``(ctx, _blocks)`` block function signature.
_block_arguments
0
ast.arguments
▼
def _block_arguments() -> ast.arguments
Returns
ast.arguments
build_stream_block_function
4
ast.FunctionDef
▼
Build a sync generator block from compiled StringBuilder statements.
build_stream_block_function
4
ast.FunctionDef
▼
def build_stream_block_function(name: str, *, preamble: list[ast.stmt], cache_assignments: list[ast.stmt], compiled_stmts: list[ast.stmt]) -> ast.FunctionDef
Parameters
| Name | Type | Description |
|---|---|---|
name |
str |
|
preamble |
list[ast.stmt] |
|
cache_assignments |
list[ast.stmt] |
|
compiled_stmts |
list[ast.stmt] |
Returns
ast.FunctionDef
build_async_stream_block_function
4
ast.AsyncFunctionDef
▼
Build an async generator block from compiled StringBuilder statements.
build_async_stream_block_function
4
ast.AsyncFunctionDef
▼
def build_async_stream_block_function(name: str, *, preamble: list[ast.stmt], cache_assignments: list[ast.stmt], compiled_stmts: list[ast.stmt]) -> ast.AsyncFunctionDef
Parameters
| Name | Type | Description |
|---|---|---|
name |
str |
|
preamble |
list[ast.stmt] |
|
cache_assignments |
list[ast.stmt] |
|
compiled_stmts |
list[ast.stmt] |
Returns
ast.AsyncFunctionDef