<div dir="ltr">Hi all, thanks for the responses, but I guess I should have been more explicit -- I'm curious about *why* PyPy is slow on existing extension modules and why people are being steered away from them.  I completely support the push to move away from CPython extension modules, but I'm not sure it's reasonable to expect that programmers will rewrite all the extension modules they use.<div>

<br></div><div style>Put another way, I understand how having a JIT-understandable cffi module will be faster on PyPy than an extension module, but what I don't quite understand is why CPython extension modules have to be slower on PyPy than they are on CPython.  I'm not saying that extension modules should be sped up by PyPy, but I'm curious why they have a reputation for being slower.</div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Mar 26, 2014 at 1:31 AM, Yury V. Zaytsev <span dir="ltr"><<a href="mailto:yury@shurup.com" target="_blank">yury@shurup.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Tue, 2014-03-25 at 16:19 -0700, Kevin Modzelewski wrote:<br>
><br>
> I'm curious, since I've heard a number of people mention that<br>
> extension modules are the primary reason that PyPy is slower than<br>
> cPython for their code; definitely an improvement over "PyPy doesn't<br>
> run my code at all", but it's made me curious about whether or not /<br>
> why it has to be that way.<br>
<br>
</div>In my opinion, it all depends on how do you use CPyExt and what your<br>
extension modules are for. There are two scenarios here (or combinations<br>
thereof) that I think cover most of the use cases:<br>
<br>
1) You use C extensions to make it faster.<br>
2) You use C extensions to steer external processes.<br>
<br>
Ideally with PyPy you should be able to drop (1) altogether and write<br>
nice Python code that JIT will be able to optimize sometimes even better<br>
than hand-written C code, so here the answer would be "don't use<br>
extensions".<br>
<br>
Now, if as a part of (2) you are doing some lengthy processing entirely<br>
outside PyPy, this might still just as fast as with CPython with CPyExt,<br>
but if the calls to your foreign functions are short and/or you are<br>
transferring a lot of data C <-> PyPy, then there you go...<br>
<br>
Personally, I've been using CPyExt and I'm very happy about it, because<br>
the function calls take a long time, and whatever happens outside<br>
doesn't have much to do with objects in PyPy land.<br>
<br>
However, if my requirements were different, I would have rather<br>
re-written everything using cffi, from what I understood it can deliver<br>
comparable performance to cPython, and also it works both for PyPy and<br>
cPython, not just PyPy...<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Sincerely yours,<br>
Yury V. Zaytsev<br>
<br>
<br>
</font></span></blockquote></div><br></div>