[Python-Dev] [compatibility-sig] do all VMs implement the ast module? (was: Re: AST optimizer implemented in Python)

fwierzbicki at gmail.com fwierzbicki at gmail.com
Tue Aug 14 00:35:35 CEST 2012


On Mon, Aug 13, 2012 at 3:10 PM, Brett Cannon <brett at python.org> wrote:

> Direct. There is an AST grammar file that gets compiled into C and Python
> objects which are used by the compiler (c version) or exposed to users
> (Python version).
At the risk of making you repeat yourself, and just to be sure I
understand: There are C objects used by the compiler and Python
objects that are exposed to the users (written in C though) that are
generated by the AST grammar. That at least sounds like they are
different. The last I checked the grammar was Python.asdl and the
translater was asdl_c.py resulting in /Python/Python-ast.c which looks
like it is the implementation of _ast.py

Are the AST objects from Python-ast.c used by the compiler? And what
is the relationship between Python-ast.c and /Python/ast.c? And what
about the CST mentioned at the top of /Python/ast.c?

I ask all of this because I want to be sure that separating the
internal AST in Jython from the one exposed in ast.py is really a good
idea. If CPython does not make this distinction that will be a strike
against the idea.

-Frank


More information about the Python-Dev mailing list