[pypy-dev] Pyrex back-end

Armin Rigo arigo at tunes.org
Thu Sep 25 21:07:20 CEST 2003


Hello everybody,

Concensus seems to araise that we should try during the sprint to obtain a
basic translator-to-low-level-code, and that Pyrex would be a nice try.

Remember that AnnObjSpace is supposed to do a complete type analysis of all
the RPython code. With Pyrex we can seriously work on the different problem of
actually emiting low-level code, before we have a really complete analysis. 
The idea is to simulate bytecode-by-bytecode the execution of the RPython
source code, and instead of actually executing the instructions, we write a
line in a .pyx (Pyrex) file. Whenever we are unsure about the type of a 
specific variable we can always fall back to generic Python objects.

Pyrex don't have gotos -- they are essential for the low-level kind of code we
can emit by blindly recording operation in an object space, because the object
space doesn't see the control structures at all (only the operations). So
Holger implemented (in 29 minutes!) a new Pyrex statement:

    cinline "anything"

which causes Pyrex to emit the given string literally in the C code it 
produces. So we can say

    cinline "Label1:"
    ...
    if condition:
        cinline "goto Label1;"

which is probably nicer than explicit "label" and "goto" statements because it
denotes clearly that it is a hack :-) It also let us emit any other C code
that we couldn't easily express in the Pyrex language.

    http://codespeak.net/svn/user/hpk/pyrex-0.8.2-hacked


A bientot,

Armin



More information about the Pypy-dev mailing list