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

Diego Jacobi jacobidiego at gmail.com
Sat Jul 19 05:00:06 CEST 2008


I am trying to decifer what exactly is the result that i got from using pypy.

As little as i understand, it can translate code from python to C.
I have followed the "Getting started" guide, but it makes it too long
to see the pypy features that i am confused.

First at all, i have had some issues from trying to compile pypy into
pypy-c, it claims for some error with cc, but cc is on my system. And
i am using debian lenny, which is still under development. Im not sure
if that can cause the problem.
So, i couldnt see the code generated or the optimiced program running.

I have found pypy, by looking for a translator from python to C.
But what i was looking for is a translator which gives me a code
without a python dependency. Maybe using stdlibs, or glib, or
something, and libffi, so the python wrappers are converted too.

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.
So, it is a python-module compiler?
Also the guide doesnt mention where is saved the resultant module.

I just want to translate a simple algoritm which i am using to test
the differences of speed between multiple languages:

By now i only have the implementation with only Python (without
external optimizations) and standard C, showing that python is only
between 20 and 40 times slower than C and a promedium of 35, which is
not much.
I want to add the code generated by pypy to compare how good is
optimiced in relation to C and Python, and in the future to other

The algorithm is very linear and doesnt make use of threads or
anything too much complicated. It does extensive use of lists and

But when running the translator with the main.py file i have an error
in an initial line:

#python pypy-dist/pypy/translator/goal/translate.py main.py

File "main.py", line 6, in <module>
    N_entradas = int(sys.argv[1])
ValueError: invalid literal for int() with base 10: 'main.py'

The program is called with 2 integers determinning the number of bits
of input and the number of bits of output in an electronic true table
which the algoritm should optimice with the QuineMcClusky algorithm.
The true table is passed through stdin.
By eample:

./main.py 3 2

That is a random table of example. An electronic should understand
that, but the fact is that the algoritm have to convert that in a set
of lists of string and work with them iterativelly, until it gets the
best possible optimization.

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.

More information about the Pypy-dev mailing list