compile() (or ast.parse(), which calls it) can return the ast for some source code, converted to a Python object version of the AST. But this AST is not optimized (with _PyAST_Optimize).
Static Python re-implemented _PyAST_Optimize for this reason. If we expose a way for them to get an optimized AST, they won't have to.
For performance, it would be better not to call another API function on a Python AST, but to add an API option that runs _PyAST_Optimize before converting the AST to Python.
Linked PRs
compile()(orast.parse(), which calls it) can return the ast for some source code, converted to a Python object version of the AST. But this AST is not optimized (with_PyAST_Optimize).Static Python re-implemented
_PyAST_Optimizefor this reason. If we expose a way for them to get an optimized AST, they won't have to.For performance, it would be better not to call another API function on a Python AST, but to add an API option that runs
_PyAST_Optimizebefore converting the AST to Python.Linked PRs