[pypy-dev] [Cython] [GSoC] Blog post regarding the Cython backend aiming PyPy

Romain Guillebert romain.py at gmail.com
Tue May 31 17:08:20 CEST 2011

On Tue, May 31, 2011 at 12:08:52PM +0200, mark florisson wrote:
> Cool. Would it be useful to always generate wrapper functions for
> extern functions with numeric argument types? E.g. this is valid
> Cython code:
> cdef extern from "foo.h":
>     ctypedef unsigned int size_t
>     size_t func_with_typedef_arg(size_t a)
> So here the ctypedef for size_t is unsigned int, which is only valid
> in C for some platforms/architectures. So perhaps a wrapper function
> could solve that issue:
> int __pyx_wrapper_func_with_typedef_arg(int a) {
>     /* some bounds and sign checking code here ? */
>     return func_with_typedef(a);
> }
> Because then you always know that calling it with argtypes = [c_int]
> and restype = c_int is valid.
> (BTW, it's also valid to declare something as a function which is
> actually a macro, so I suppose you always need wrappers for
> functions.)
> Do you already have an idea how to handle struct type arguments? Those
> are often also incomplete... but perhaps I'm geting too far ahead, I
> don't think we're quite there yet. I suppose you could also place this
> ABI burden on the user (for now), as does ctypes.
> As for the linking stuff, perhaps it's a good idea to look at
> http://wiki.cython.org/enhancements/distutils_preprocessing (currently
> down unfortunately, but in google cache). Then you can list libraries
> like this: '# distutils: libraries = spam eggs' at the top of the
> file.
> Cheers,
> Mark

Hi Mark

For the moment, I try to handle the standard case : call a function with
C basic types, then add structures and pass by pointer.
To deal with the ABI, fijal told me that there's a tool called
ctypes_configure, I will investigate this to see what I can get from it.


More information about the pypy-dev mailing list