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 - seems like CPython is one of its only somewhat-visible users these days] Thanks in advance, Eli
2013/9/25 Eli Bendersky <eliben@gmail.com>:
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.
Sorry, what Python 2.4 ast stdlib module? Any module named "ast" (or "_ast") didn't exist until 2.5. -- Regards, Benjamin
On Wed, Sep 25, 2013 at 9:28 AM, Benjamin Peterson <benjamin@python.org>wrote:
2013/9/25 Eli Bendersky <eliben@gmail.com>:
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.
Sorry, what Python 2.4 ast stdlib module? Any module named "ast" (or "_ast") didn't exist until 2.5.
I think Eli is talking about the compiler package's own AST.
On Wed, Sep 25, 2013 at 6:28 AM, Benjamin Peterson <benjamin@python.org>wrote:
2013/9/25 Eli Bendersky <eliben@gmail.com>:
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.
Sorry, what Python 2.4 ast stdlib module? Any module named "ast" (or "_ast") didn't exist until 2.5.
Lib/compiler/ast.py (that's in 2.4) Sorry, I should have been more precise
On Wed, Sep 25, 2013 at 6:35 AM, Eli Bendersky <eliben@gmail.com> wrote:
On Wed, Sep 25, 2013 at 6:28 AM, Benjamin Peterson <benjamin@python.org>wrote:
2013/9/25 Eli Bendersky <eliben@gmail.com>:
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.
Sorry, what Python 2.4 ast stdlib module? Any module named "ast" (or "_ast") didn't exist until 2.5.
Lib/compiler/ast.py (that's in 2.4)
Sorry, I should have been more precise
http://docs.python.org/release/2.4/lib/module-compiler.ast.html
cc'ing Jeremy Hylton who made the decision to use Zephyr. On Wed, Sep 25, 2013 at 9:15 AM, Eli Bendersky <eliben@gmail.com> wrote:
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 - seems like CPython is one of its only somewhat-visible users these days]
Thanks in advance, Eli
participants (3)
-
Benjamin Peterson -
Brett Cannon -
Eli Bendersky