[Cython] CTypes backend for Cython Status

Romain Guillebert romain.py at gmail.com
Fri Sep 9 23:41:30 CEST 2011


Hi Stefan

On Fri, Sep 09, 2011 at 10:35:20AM +0200, Stefan Behnel wrote:
> Hi Romain,
> 
> thanks for the feedback.
> 
> Romain Guillebert, 08.09.2011 06:18:
> >The Google Summer of Code has ended and I didn't give the current status
> >to anyone yet (I was very busy with a report I had to write for my
> >university).
> >
> >There is still work to do on the project (there was more work than I
> >expected, especially because of semantic differences between Cython and
> >ctypes) so I'll talk about what needs to be done (even if it does not
> >sound good compared to talking about what has been done) from the most
> >important to the least important in my opinion :
> >
> >- Pointer vs Array, Cython mixes the two while ctypes does not, this
> >   can probably be fixed by using arrays everywhere (if we can convert
> >   pointers into arrays)
> 
> Could you elaborate on this? Why can't you always use pointers?
> 

You can't do array indexing on ctypes pointers (and no straightforward
pointer arithmetic either)

> 
> >- Take into account header files declared globally
> 
> "globally" as in ... ?
> 
> And what exactly do you mean by "take header files into account"?
> 

Take into account : pass to ctypes_configure

And I didn't want to say globally, but right now I only pass to
ctypes_configure the header file given by "cdef extern from" and from my
tests it's not enough

> 
> >- Macros, this is probably the biggest part but it's doable, Cython has
> >   the types of the arguments and the return value so it's possible to
> >   generate a C function corresponding to a macro
> 
> Agreed. I think that's the only viable solution. Won't work for all
> macros, but at least for a rather large number of them.
> 
> 
> >- Pointer to functions
> 
> I take it this isn't implemented at all? Do you mean pointers to
> Cython cdef functions or also to external C defined functions?
> 

Pointer to cdefed functions and pointers to function returned by C
functions (although I don't know for the later but it would surprise me)

> 
> >Some of them are trivial, others just require good ideas and macros
> >demands a big amount of work.
> 
> Really? Apart from generating the rather straight forward wrapper
> functions for them, what else needs to be done?
> 

You have to include the right headers and take care of the types (if a type
is ctypedefed there's probably something to do)

> 
> >I'm still working on it and if someone wants to give a hand, I'll be
> >happy to explain what I've done.
> 
> Happy to hear that.
> 
> Stefan

Romain


More information about the cython-devel mailing list