[Python-Dev] Psyco1 with Stackless

Christian Tismer tismer@tismer.com
Thu, 05 Jul 2001 17:16:20 +0200

Hi Armin, developers,

I had a closer look at your Python Specializing Compiler.
This is a very promising approach, going into directions
which I have been trying a little myself.

In its current state, Psyco introduces a nice little extra engine,
which mostly deals with efficient integer operations. There are
a lot of other optimizations possible, and lots of opcodes need
to be implemented in order to make it usable for real world
applications. Anyway, I found this proof of concept very interesting,
and so I built the extensions for Win32 (with very small changes)
and did some testing with mctest.py .

Here my results with stock Python 2.0:
result 1952145856 in 2.43729775712 seconds
result 1952145856 in 2.18692571263 seconds
result 1952145856 in 5.60894890272 seconds

(run1, run2, original func)

But before, I tested with Stackless Python by chance, and I got this:
result 1952145856 in 2.42536300005 seconds
result 1952145856 in 2.18817615088 seconds
result 1952145856 in 3.51236064919 seconds

While your result outperforms standard Python by 2.56, it performs
only by 1.605 better than Stackless!

This doesn't say anything against your implementation, instead it
tells me that Stackless' code optimization is much better than
Standard Python's, especially for integer operations on Win32.
For sure, your version could be much faster when it is generating
machine code, or if even more optimizations of data flow are
Your little vm looks already very efficient. The is of course some
room for optimizations, like this: the SGET macro is used all around,
and it always uses explicit stack addressing. A function like
       CODE_INT_BINARY(IntSub, -)
expands into 16 machine instructions with Visual Studio 6.
For common cases, like  [TOS-1] = [TOS] - [TOS-1], special
accessors might save about half of these opcodes, again.

In other words, I assume that you can get three times as fast
as Python on integer operations with just a VM.

Congratulations and keep this work on! - chris

p.s.: Note that at the moment, you don't do any overflow checks
on integers. This is not cmpatible to Python, while I would
love to have an option to switch of overflow checks in Python,
of course!

Christian Tismer             :^)   <mailto:tismer@tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net/
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     where do you want to jump today?   http://www.stackless.com/