On 16/09/20 9:34 am, Pablo Galindo Salgado wrote:
> The first is that deleting a deep tree
> currently is just freeing the arena block, while if the nodes were
> PyObjects it will involve recursive destruction. That could potentially
Not sure why that would be a concern. It's theoretically a possibility
with any Python data, but we don't seem to worry about it. Why should
it be a problem in the compiler specifically?
Oh, we do worry about it. Grep the source code for "trashcan" (case-insensitively). It's all over the low-level container data structures.
> * The proposal seems to imply that the AST will be a fully public and
> stable API.
We already have two kinds of AST, the one used internally by the
compiler, and the one exposed to Python in the ast module. The only
time the latter should need to change is if there is a change in
the syntax of the language, so why not promise to keep it stable
and use it as the form taken and produced by the macro processors?
Currently (in CPython) the two have the same structure, and if a release changes the one it changes the other.
Historically we've regularly changed the AST incompatibly (in feature releases only). Sometimes a new grammar feature makes it convenient to change the AST generated even for constructs whose grammar didn't change. We've also changed the way literals were represented from separate String and Number nodes to a more general Constant node type.
IMO if we were to standardize the AST for times immemorial this would have to be a separate PEP.