[pypy-dev] cpyext performance

Stefan Behnel stefan_ml at behnel.de
Wed Jul 4 20:53:07 CEST 2012

Stefan Behnel, 03.07.2012 19:56:
> Amaury Forgeot d'Arc, 03.07.2012 18:26:
>> Then this should work:
>>    pypy/bin/py.py --withmod-cpyext -c "import nbody"
>> *very* slowly of course, but I was able to debug pygames this way!
> The problem is not so much that it's generally slow but that the
> performance characteristics of the Python code are likely way different
> than those of the translated C code. That's certainly the case for Cython
> code, running cProfile over Python code, running it over the compiled
> module and running callgrind over it often yields totally different
> results. That's why I would prefer running this through callgrind instead
> of Python+profile (I noticed that cProfile doesn't work either).

Actually, it did work. I just had to enable the _lsprof module.

However, it now prints a trace of every C-API function that it calls, e.g.

<function PyTuple_CheckExact at 0x42da5a0>  DONE
<function PyList_CheckExact at 0x43cc5a0>  DONE
<function PySequence_Size at 0x43e1300>  DONE
<function PySequence_ITEM at 0x43ef300>  DONE
<function PySequence_ITEM at 0x43ef300>  DONE
<function PySequence_ITEM at 0x43ef300>  DONE
<function Py_DecRef at 0x40aea38> <function subtype_dealloc at 0x4322990>
<function PyObject_dealloc at 0x43466f0> <function PyObject_Del at
0x43464f8>  DONE

Is there a way to disable that? That level of verbosity could be a bit costly.


More information about the pypy-dev mailing list