python reduce constants at run or compile?

Skip Montanaro skip at mojam.com
Thu Sep 7 00:13:02 EDT 2000


Pete asks about

    * constant expression evaluation
    * constant propagation

By the current compiler, no.  Various people have demonstrated/developed
tools to do this.  I wrote a peephole optimizer once that works (worked -
it's been quite awhile since I looked at it) that performed some of these
sorts of transformations.  My optimizer is sitting as a context diff against
1.5.1 at

    http://www.musi-cal.com/~skip/python/optimizer.patch

Another much more recent activity is the byte code hacks stuff.  I've never
fiddled with it, but I understand it's a set of tools for manipulating
Python byte code in various ways that probably overlaps with what you would
normally think of as optimization.  Check the project out at

    http://bytecodehacks.sourceforge.net/

-- 
Skip Montanaro (skip at mojam.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list