Psyco Specializing Compiler

Terry Reedy tjreedy at home.com
Wed Oct 10 23:33:43 EDT 2001


"Rigo Armin" <arigo at belgacom.net> wrote in message
news:3bc4d2e4$0$36473$ba620e4c at news.skynet.be...
> Hello everybody,
>
> "Psyco", the Python Specializing Compiler I introduced some time ago
on the
> python-dev mailing list, is beginning to work. Its goal is to
accelerate
> execution of any Python program by dynamically compiling several
> "specialized" versions of your code directly in machine code. For
more info
> see
>
>    http://homepages.ulb.ac.be/~arigo/psyco/

An interesting project.  If I understand properly, you are dynamically
compiling small chunks of PyCode to machine code according to the
actual run-time type of the values involved in the chunk.  Its a
little mind-bending at first, like metaclasses and Stackless.

You say that your system saves the compiled machine code for a
function, after the function exits, for later reuse.   Are the saved
chunks tagged with the specific types used in the compilation, so the
the system will recompile a function if/when entered with different
types?  (This would be something like C++ compiling alternate versions
of a template for different types.)

While aiming for completeness is good, speeding up just arithmetic
functions would be an important contribution.  You might consider
making explicit assumptions that programmers using your system do not
pathologically rebind variables.  For instance, tail recursion
elimination requires that the name of the recursing function not be
rebound to anything else during the recursion.

> Currently works on very simple examples only, but quite well: with
an
> acceleration factor of 100, including the compilation time! I expect
a
> factor of about 10 in compiling real code.

Do you have any actual numbers?

> Python is known to be "impossible to compile". Psyco shows that it
is only
> half the story. True, Psyco does not statically compile your code,
so don't
> expect to turn a .py file into a stand-alone .exe file. This still
requires
> the full interpreter. But Python or any other interpreted language
can
> theoretically be run as fast as fully optimized C. If you don't
believe it
> wait for a full-featured Psyco. It won't be as fast as C but it will
> probably be faster than you believed was possible :-)
>
> Armin Rigo

Terry J. Reedy






More information about the Python-list mailing list