[Python-Dev] AST optimizer implemented in Python

Hrvoje Niksic hrvoje.niksic at avl.com
Tue Aug 14 17:09:13 CEST 2012


On 08/14/2012 03:32 PM, Victor Stinner wrote:
>> I had the idea (perhaps not an original one) that peephole optimization would be much better
>> done in python than in C. The C code is clunky and unwieldly, wheras python would be much
>> better suited, being able to use nifty regexes and the like.
>>>> The problem is, there exists only bytecode disassembler, no corresponding assembler.
>> Why would you like to work on bytecode instead of AST? The AST
> contains much more information, you can implement better optimizations

AST allows for better high-level optimizations, but a real peephole 
optimization pass is actually designed to optimize generated code. This 
allows eliminating some inefficiencies which would be fairly hard to 
prevent at higher levels - wikipedia provides some examples.


More information about the Python-Dev mailing list

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