[Python-Dev] Enable access to the AST for Python code

Nick Coghlan ncoghlan at gmail.com
Thu May 21 06:57:45 CEST 2015

On 21 May 2015 at 12:31, Guido van Rossum <guido at python.org> wrote:
> Hey Ben, this is probably a better topic for python-ideas. I'll warn you
> that a hurdle for ideas like this is that ideally you don't want to support
> this just for CPython. It's definitely cool though! (Using movie poster
> style quotes you can turn this into a ringing endorsement: "definitely cool"
> -- The BDFL. :-)

Agreed this is python-ideas territory, but yes there's definitely
interest in being able to mark a section of code as being compiled to
an AST object at compile time, and then further processed at runtime
(essentially having syntax to switch on PyCF_ONLY_AST for a
subexpression and/or entire statement).

At the moment, you can do this all through the ast module and the
PyCF_ONLY_AST flag to compile(), but you need to pass the code to be
compiled around as strings, which tends to somewhat user (and IDE!)


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list