[Python-Dev] astgen.py vs. ASDL for ASTs (original) (raw)

Eli Bendersky eliben at gmail.com
Wed Sep 25 15:15:19 CEST 2013


Hello,

Some history (as best as I could collect it) followed by a question:

Before Python 2.5, the ast stdlib module was auto generated by a script named astgen.py from a textual AST definition in Tools/compiler/ast.txt.

Since 2.5 (http://www.python.org/dev/peps/pep-0339/) ASTs are part of the normal compilation flow by the Python compiler itself, and the ast module uses the same ASTs generated from Parser/Python.asdl

My question is, when the switch was made in 2.5 - why didn't the existing AST-generating code was used and the path moved to ASDL instead? What advantages does ASDL have over the previous approach? One reason I could think of is that ASDL nodes are typed and that's maybe better for the generated C code to handle.

[My interest here is personal. One of my projects (pycparser) uses a astgen.py-like approach, and in a new project I'm considering the options again and remembered ASDL. ADSL's documentation it extremely scarce online

Thanks in advance, Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130925/c16b75c0/attachment.html>



More information about the Python-Dev mailing list