<br><br><div><span class="gmail_quote">On 11/21/06, <b class="gmail_sendername">tomer filiba</b> <<a href="mailto:firstname.lastname@example.org">email@example.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
i read the references fredrik posted several days back, and it got<br>me thinking: why not add a "co_ast" attribute to code objects?<br><br>i.e., since (virtually) all code objects are constructed from source<br>
code by compilation, the compiler could just emit the AST as an<br>attribute to the generated code object.<br><br>yes, there's an issue of memory consumption, but bear with me<br>for a moment. also, maybe co_ast could be a lazy attribute, reading
<br>the ast from the pyc file on demand.</blockquote><div><br>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.
<br></div><br>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.<br><br>