[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pypy-dev
Subject:    Re: [pypy-dev] libgmp
From:       "Amaury Forgeot d'Arc" <amauryfa () gmail ! com>
Date:       2012-02-24 9:27:30
Message-ID: CAGmFidbUiEiMUbNn7eMEB4ARDioqZ2WDUi52aOHJZJ=nY23mbg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Stefan,

2012/2/24 Stefan Behnel <stefan_ml@behnel.de>

> So, as a reply to the OP: seeing the current advances in getting Cython
> code to run in PyPy (interfacing at the C-API level), another option would
> be to do exactly as you would in CPython and implement the performance
> critical parts of the code that heavily rely on gmp interaction in Cython
> (to get plain C code out of it), and then import and use that from PyPy,
> but at a much higher level than with direct individual calls to the gmp
> functions. However much faster ctypes can be in PyPy than in CPython, you
> just can't beat the performance of a straight block of C code when the goal
> is to talk to C code. Cython will also allow you to run code in parallel
> with OpenMP, in case you need that.
>

Cython won't be fast with PyPy. The C code it generates is too much
specialized for CPython.
For example, I've seen huge slowdowns in the Cython program itself (while
compiling lxml, for example)
when the various Cython extension modules (Nodes.c for example) started to
compile and became
available for pypy.
I was about to write the list of operations that cpyext performs for
PyTuple_GET_ITEM,
but this macro is too large to fit in the margin :-)
And PyDict_Next is a nightmare:
https://bitbucket.org/pypy/pypy/src/9f0e8a37712b/pypy/module/cpyext/dictobject.py#cl-177

It's one thing to be able to run lxml and other Cython-based libraries with
pypy.
it's another thing to pretend that Cython is the way to write fast modules
on pypy.
You may win on the generated C code, but will loose when interfacing with
the rest
of the Python interpreter (which is also the reason why ctypes is so slow).

This said, I've added all the functions you mentioned in a previous email.
You may try your tests again with the nightly build.

-- 
Amaury Forgeot d'Arc

[Attachment #5 (text/html)]

Hi Stefan,<br><br><div class="gmail_quote">2012/2/24 Stefan Behnel <span \
dir="ltr">&lt;<a href="mailto:stefan_ml@behnel.de">stefan_ml@behnel.de</a>&gt;</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&#39;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&#39;t \
be fast with PyPy. The C code it generates is too much specialized for \
CPython.<div>For example, I&#39;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.p \
y#cl-177">https://bitbucket.org/pypy/pypy/src/9f0e8a37712b/pypy/module/cpyext/dictobject.py#cl-177</a></div>
 <div><br></div><div>It&#39;s one thing to be able to run lxml and other Cython-based \
libraries with pypy.</div><div>it&#39;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&#39;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&#39;Arc<br> </div></div><div><br></div>



_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
http://mail.python.org/mailman/listinfo/pypy-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic