parse-time optimizations

Skip Montanaro skip at pobox.com
Wed May 30 11:47:01 EDT 2001


    jcm> Don't just think of the program text--these transformations would
    jcm> be done on the parse-tree.  In Python '+' is left-associative.
    jcm> We're talking about simple, well-understood optimizations.  

I wrote a paper for the Python conference in November 1998 on a peephole
optimizer.  The paper is available at

    http://www.foretec.com/python/workshops/1998-11/proceedings/papers/montanaro/montanaro.html

The code included a ConstantExpressionEvaluator class.  I think the
bytecodehacks stuff has similar capability.  For a potentially nice
framework for (re)implementing this stuff, look at Jeremy Hylton's byte code
compiler in Tools/compiler in the Python 2.1 distribution.

If anyone is interested in reviving such tools, let me know.  I don't have
time to work on this now, but would be willing to send you my (outdated)
code.

-- 
Skip Montanaro (skip at pobox.com)
(847)971-7098




More information about the Python-list mailing list