[Python-ideas] Could the ast module's ASTs preserve source_length in addition to lineno and col_offset?

Haoyi Li haoyi.sg at gmail.com
Thu May 30 02:04:44 CEST 2013


I don't need to keep the source code, I just need a single integer for each
node. I would then be able to reconstruct the source snippet.




On Wed, May 29, 2013 at 7:47 PM, Steven D'Aprano <steve at pearwood.info>wrote:

> On 30/05/13 09:06, Haoyi Li wrote:
>
>  I want the original source code for debugging/tracing purposes
>>
>
> Do you have an idea of the memory overhead of keeping the source code
> around?
>
> Is it worth having the ast module honour the __debug__ flag (-O and -OO
> switches), and *not* preserve source when optimizations are in effect? That
> may mean that some ast operations cannot run under -O or -OO, in the same
> way that code that cares about __doc__ strings cannot meaningfully run
> under -OO. That's okay by me.
>
>
>
> --
> Steven
> ______________________________**_________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/**mailman/listinfo/python-ideas<http://mail.python.org/mailman/listinfo/python-ideas>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130529/794415c5/attachment-0001.html>


More information about the Python-ideas mailing list