[pypy-dev] Question about extension support

John Camara john.m.camara at gmail.com
Wed Mar 26 02:48:27 CET 2014


Hi Kevin,

More up to date information can be found on the FAQ page

http://doc.pypy.org/en/latest/faq.html#do-cpython-extension-modules-work-with-pypy

The best approach for PyPy is either use a pure Python module if possible
or use a cffi wrapped extension instead of an extension that uses the
CPython CAPI.  Often CPython CAPI extensions are wrapping some c library.
 Creating a cffi wrapper for the library is actually much simpler than
writing a CPython CAPI wrapper.  Quite a few CPython CAPI extensions have
already been wrapped for cffi so make sure to search for one before
creating your own wrapper. If you need to create a wrapper, refer to the
cffi documentation at

http://cffi.readthedocs.org/en/release-0.8/

Extensions wrapped with cffi are compatible with both CPython and PyPy.  On
CPython the performance is similar to what you would get if you used
ctypes.  How every, under PyPy, the performance is much closer to a native
C call plus the overhead for releasing and acquiring the gil.

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20140325/7e3679ae/attachment.html>


More information about the pypy-dev mailing list