[Python-Dev] Memory management in the AST parser & compiler

Nick Coghlan ncoghlan at gmail.com
Wed Nov 30 10:42:20 CET 2005


Greg Ewing wrote:
> Neal Norwitz wrote:
>>> I'm mostly convinced that using PyObjects would be a good thing. 
>> However, making the change isn't free as all the types need to be
>> created and this is likely quite a bit of code.
>> Since they're all so similar, perhaps they could be
> auto-generated by a fairly simple script?
>> (I'm being very careful not to suggest using Pyrex
> for this, as I can appreciate the desire not to make
> such a fundamental part of the core dependent on it!)

The ast C structs are already auto-generated by a Python script (asdl_c.py, to 
be precise). The trick is to make that script generate full PyObjects rather 
than the simple C structures that it generates now.
I believe Jeremy wrote that early in the life of the AST branch, so it's worth 
waiting for his advice on how to go about modifying it.
asdl_seq can disappear entirely: we can just use a PyList instead.
The second step is to then modify ast.c to use the new structures. A branch 
probably wouldn't help much with initial development (this is a "break the 
world, check in when stuff compiles again" kind of change, which is hard to 
split amongst multiple people), but I think it would be of benefit when 
reviewing the change before moving it back to the trunk.
Cheers,
Nick.
-- 
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
 http://www.boredomandlaziness.org


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /