[pypy-dev] offtopic, ontopic, ...

Antonio Cuni anto.cuni at gmail.com
Tue Feb 14 19:10:11 CET 2012

On 02/14/2012 06:56 PM, Stefan Behnel wrote:
> Ok, then I take it that this would be the preferred Python+FFI approach for
> interfacing, right? ctypes is out of the loop?

note that there are at least two different levels to interface with C code.

The first is using rffi, which lets you to call C code from RPython. Calls to 
rffi functions are translated into C calls at translation time.

Then, there is the ctypes-like approach, which lets you to call C from 
applevel code, which is basically a layer on top of libffi.
The ctypes approach has some pretty important advantages, e.g. you don't need 
a compiler, people don't need to learn another language, the development is 
faster, etc.

On the other hand, I think that most of us agree that the ctypes interface is 
terrible. What I would like is an ffi module which is applevel but with a much 
nicer interface. And, the JIT compiler can turn these calls into very 
efficient machine code.

We do need both alternatives in PyPy, if anything because ctypes or this 
yet-to-come "ffi" module need to be implemented in RPython and thus depends on 
However, once it's ready the ffi module should ideally be powerful enough to 
interface with all the C code out there.


More information about the pypy-dev mailing list