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

Steven D'Aprano steve at pearwood.info
Thu May 30 01:47:28 CEST 2013


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


More information about the Python-ideas mailing list