Classes
_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
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]