Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does pypy support cython extension?

I have a project which runs is run in pypy (and already achieves a nice speedup over its python counterpart). However, I do have a Cython implementation of one function which is way faster than the pypy version. So I would like to include this function.

The problem is that pypy does not seem to find this module (even though the .so lies in the same folder as the executed .py script):

ImportError: No module named foo

Hence, does pypy support cython? Thanks.

like image 237
user1829358 Avatar asked Jan 07 '13 18:01

user1829358


1 Answers

If you want to make Cython extension available under PyPy, you have to recompile it and reinstall it under PyPy. I suggest using a virtualenv for that, to start with. However, if this is purely for speedups, I would really really discourage you from doing so. The CPyext (CPython C API emulation) is really slow and you're very likely ending up with a slowdown. On the other hand, optimized Python should run under PyPy as fast as optimized Cython (with types).

Cheers, fijal

like image 102
fijal Avatar answered Oct 11 '22 23:10

fijal