[Cython] Automatic conversion with fixed-size C arrays

Kurt Smith kwmsmith at gmail.com
Wed Jul 16 19:01:50 CEST 2014


Hi devs,

Being able to convert between simple C structs and Python dictionaries is
great, but it doesn't work if there is a fixed-size array field in the
struct.  It seems like the following struct should be convertible safely:

cdef struct state_t:
    int i, j, k
    float x[3]
    float v[3]

Along with that, I'd expect that converting between fixed-sized C arrays
and Python iterables should work as well:

def auto_convert(list ll):
    cdef int arr[10] = ll
    # ...
    return arr

If this is deemed something worth doing and if someone is willing to give
pointers when I get stuck, I'm offering to put in the development time to
implement this.

Thoughts?

Kurt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20140716/221589eb/attachment.html>


More information about the cython-devel mailing list