[pypy-dev] I have a problem interpreting pypy functionality.

Neil Shepperd nshepperd at gmail.com
Mon Jul 21 08:41:47 CEST 2008


On Sat, 2008-07-19 at 00:00 -0300, Diego Jacobi wrote: 
> What i understand of the error line, is that it cant convert 'main.py'
> to integer.
> So seems like argv is like ['python pypy-dist/pypy/.....','main.py']
> Does the translator haves to run the code to translate it?
> The 'main.py' should be the first argument received by the program not
> the second one.
> How can i pass any argument in the right order?
> Thanks in advance.
> Diego.

The pypy translator is not a *module* translator. It takes an
entry-point function (equivalent to main() in C) and converts that to C.
Take a look at pypy/translator/goal/target-nopstandalone.py
to see how it is defined.

The important thing is that any code you want to translate into C must
be placed in a function (and obviously used by the entry-point
function). Code in the module body itself will be executed immediately
by the translator (under Python interpreter).

> In some of the tests in the guide i see that after compiling with
> t.compile_c() i can directly use the function in python.
The function is converted to C and compiled to an extension module
(DLL). This module is saved in a temporary directory somewhere (/tmp).
It's probably not a good idea to try to open that file itself, better to
just use the (compiled) function returned by compile_c().

Hope I make sense.

More information about the Pypy-dev mailing list