[pypy-dev] clarification cffi vs _ffi_ vs _ffi vs libffi vs _rawffi vs rffi

Armin Rigo arigo at tunes.org
Wed Nov 27 17:24:10 CET 2013


Hi Dima,

On Wed, Nov 27, 2013 at 4:07 PM, Dima Tisnek <dimaqq at gmail.com> wrote:
> there seems to be some confusion (could be all mine) between N terms
> related to FFI:

As a user of PyPy you only need to concern yourself with cffi and
ctypes.  The rest is all a number of more-or-less related internal
sub-parts of PyPy or the RPython translation toolchain that all
attempt to do accessing C-level functionality: rffi, _ffi, _rawffi.
And libffi is the existing, non-PyPy-related, C library that is
(sometimes) used by these other levels.

> docs in question:
> http://doc.pypy.org/en/latest/faq.html
> http://doc.pypy.org/en/latest/extending.html
> http://doc.pypy.org/en/latest/rffi.html

"rffi" is about writing RPython code, e.g. a special extension module
for PyPy; in most cases you don't need that.  The page
http://doc.pypy.org/en/latest/extending.html is a bit outdated :-(
Thanks for pointing it out.

> in my own testing, I noticed that equivalent code cffi code is faster
> than ctypes, is there an explanation for this?

On top of PyPy, yes, definitely.  CFFI is simpler than ctypes; it was
*designed* to be simple.  Although it was not particularly designed
for PyPy and works fine on CPython (and was actually first developed
for CPython), this has the intended benefit that PyPy's JIT can do a
good job on it.


A bientôt,

Armin.


More information about the pypy-dev mailing list