[Numpy-discussion] Cython 0.10 released, more NumPy features
Dag Sverre Seljebotn
Sun Nov 9 17:01:16 CST 2008
As the latest Cython 0.10 release has some important news for
Cython/NumPy users, I decided to post an announcement (hope that's ok).
Download at <http://cython.org>
What's new for NumPy users:
1) Support for access to complex float buffers. Cython does not have
native complex float syntax support , so this is by using structs:
cdef struct cdouble:
cdef np.ndarray[cdouble, ndim=2] arr = np.zeros((3,3), np.cdouble)
arr[0,1].real = 3
2) Also support for record arrays:
cdef MyStruct rec
cdef np.ndarray[MyStruct] arr = np.zeros((3,), np.dtype('i4,i1,i1'))
rec.one, rec.two, rec.three = range(1,4)
arr = rec
print arr.two # prints 2
There's some restrictions though -- in general the data buffer must be
directly cast-able to the given struct type; there's no automatic
endian-conversion or anything like that.
3) Support for contiguous access, which makes for quicker array access
along the last/first dimension if you know you have contiguous data:
cdef np.ndarray[int, mode="c"] arr = ...
I am likely not going to work to add features beyond this, at least this
time around (but there might be minor tweaks and fixes). If anybody
would like to use this but there's still showstoppers I'm unaware of
then please let me know.
 It has been discussed and native complex support would be added to
Cython if someone found time to implement it, but I can't, unfortunately.
More information about the Numpy-discussion