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

mark florisson markflorisson88 at gmail.com
Tue May 31 12:11:42 CEST 2011


On 30 May 2011 23:31, Romain Guillebert <romain.py at gmail.com> wrote:
> Hi
>
> I've posted and article on my blog that explains what I've done during
> the community bonding period and the first week of the Google Summer of
> Code :
> http://rguillebert.blogspot.com/2011/05/cython-backend-aiming-pypy-week-1.html
>
> Cheers
> Romain
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel
>

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


More information about the pypy-dev mailing list