[Python-3000] LINQ

Brett Cannon brett at python.org
Wed Nov 22 19:05:36 CET 2006


On 11/21/06, tomer filiba <tomerfiliba at gmail.com> wrote:
>
> i read the references fredrik posted several days back, and it got
> me thinking: why not add a "co_ast" attribute to code objects?
>
> i.e., since (virtually) all code objects are constructed from source
> code by compilation, the compiler could just emit the AST as an
> attribute to the generated code object.
>
> yes, there's an issue of memory consumption, but bear with me
> for a moment. also, maybe co_ast could be a lazy attribute, reading
> the ast from the pyc file on demand.


Because the .pyc file does not store enough information for an easy
bytecode->AST transformation.  You would need to read from the source code
and and reconstruct the AST.

This is why, as of now, you need to go through compile() to get an AST.  I
personally would rather wait to see how much the AST is actually used before
trying to give it an attribute on code objects.

-Brett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20061122/4734ad25/attachment.html 


More information about the Python-3000 mailing list