Python AST, Codegen & Source Transformation
Parent: Programming Languages · researched 2026-06-02T18:13:44.156Z· 5 sources · 7 concepts · skill python-ast-codegen
Children
- ast module (parse, NodeVisitor/NodeTransformer, fix_missing_locations, compile, unparse 3.9+, literal_eval) (frontier)
- AST is lossy -> when you need a CST (frontier)
- LibCST (lossless CST, matchers, metadata, codemod framework, 3.0-3.14) (frontier)
- Import hooks (sys.meta_path finders/loaders, source_to_code, PEP 302/451) (frontier)
- Code generation (ast.unparse, astor/astunparse, compile+exec, string templating tradeoff) (frontier)
- Use cases (linters/formatters, codemods, instrumentation, DSLs/PEP 750) (frontier)
- Pitfalls (AST version drift, locations, exec/eval/pickle security, round-trip loss) (frontier)
Frontier under this node: AST is lossy -> when you need a CST, Code generation (ast.unparse, astor/astunparse, compile+exec, string templating tradeoff), Import hooks (sys.meta_path finders/loaders, source_to_code, PEP 302/451), LibCST (lossless CST, matchers, metadata, codemod framework, 3.0-3.14), Pitfalls (AST version drift, locations, exec/eval/pickle security, round-trip loss), Use cases (linters/formatters, codemods, instrumentation, DSLs/PEP 750), ast module (parse, NodeVisitor/NodeTransformer, fix_missing_locations, compile, unparse 3.9+, literal_eval)