[Python-Dev] Expression optimizations

Raymond Hettinger python at rcn.com
Tue Feb 10 22:20:38 CET 2009


[Cesare Di Mauro]
> I'm playing with the virtual machine and I have some ideas about possibile
> optimizations that could be applyed. But I need to verify them, so
> understanding what is possible and what is not, is a primary goal for me.

The best way to understand what is possible is to disassemble bytecode
and the look at *exactly* how those are executed by ceval.c.  That makes
it possible to identify which transformations are semantically neutral.

FWIW, I think the path of peephole optimizing been mostly exhausted.
A much more fertile field of search is to examine what can be done with
the AST.  Sections of the tree may provide more context so that a broader
range of simplifications and transformations are possible.

This should discussion probably be taken off python-dev and moved to 
to comp.lang.python until the exercise has grown beyond "playing with
the virtual machine."

Raymond


More information about the Python-Dev mailing list