Hi Stefan,<br><br><div class="gmail_quote">2012/2/24 Stefan Behnel <span dir="ltr"><<a href="mailto:stefan_ml@behnel.de">stefan_ml@behnel.de</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":2ne">So, as a reply to the OP: seeing the current advances in getting Cython<br>
code to run in PyPy (interfacing at the C-API level), another option would<br>
be to do exactly as you would in CPython and implement the performance<br>
critical parts of the code that heavily rely on gmp interaction in Cython<br>
(to get plain C code out of it), and then import and use that from PyPy,<br>
but at a much higher level than with direct individual calls to the gmp<br>
functions. However much faster ctypes can be in PyPy than in CPython, you<br>
just can't beat the performance of a straight block of C code when the goal<br>
is to talk to C code. Cython will also allow you to run code in parallel<br>
with OpenMP, in case you need that.<br></div></blockquote></div><br>Cython won't be fast with PyPy. The C code it generates is too much specialized for CPython.<div>For example, I've seen huge slowdowns in the Cython program itself (while compiling lxml, for example)</div>
<div>when the various Cython extension modules (Nodes.c for example) started to compile and became</div><div>available for pypy.</div><div>I was about to write the list of operations that cpyext performs for PyTuple_GET_ITEM,</div>
<div>but this macro is too large to fit in the margin :-)</div><div>And PyDict_Next is a nightmare:</div><div><a href="https://bitbucket.org/pypy/pypy/src/9f0e8a37712b/pypy/module/cpyext/dictobject.py#cl-177">https://bitbucket.org/pypy/pypy/src/9f0e8a37712b/pypy/module/cpyext/dictobject.py#cl-177</a></div>
<div><br></div><div>It's one thing to be able to run lxml and other Cython-based libraries with pypy.</div><div>it's another thing to pretend that Cython is the way to write fast modules on pypy.</div><div>You may win on the generated C code, but will loose when interfacing with the rest</div>
<div>of the Python interpreter (which is also the reason why ctypes is so slow).</div><div><br></div><div>This said, I've added all the functions you mentioned in a previous email.</div><div>You may try your tests again with the nightly build.</div>
<div><div><div><br></div>-- <br>Amaury Forgeot d'Arc<br>
</div></div><div><br></div>