[Python-Dev] Expression optimizations

Cesare Di Mauro cesare.dimauro at a-tono.com
Tue Feb 10 22:53:54 CET 2009


On Mar, Feb 10, 2009 10:20PM, Raymond Hettinger wrote:
> [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.

I've already done it, but ceval.c isn't enough. It makes use of external
functions to do some works, like PyObject_RichCompare, for example. So
I've asked some information here.

> FWIW, I think the path of peephole optimizing been mostly exhausted.

I think so too, but there's room for a few optimizations (introducing some
new opcodes).

> 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.

I completely agree.

> 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

I've already rewritten ceval.c, opcode.h and some other files of Python
2.6.1 to implement my ideas. I think it's a little bit beyond "playing"
with the VM, and I hope to present my work to the next PyCon at Florence,
in Italy, if my paper will be accepted.

Now I'm trying to understand how compiler.c works, to fit in my changes (I
took a look at peephole.c, and it'll be easier, fortunately, but I'll do
it later).

It's not easy for me, since I'm alone, I'm working to a code which is not
mine, and a bit complicated too.

But if you think that this mailing list is not the correct place to ask
for, I'll move to comp.lang.python, as you have suggested.

Thanks,
Cesare


More information about the Python-Dev mailing list