Since there's been a lot of Cython discussion lately I thought I'd speak
up and start a thread specifically for my project.

We've just recently set a clear direction for my Google Summer of Code
project for integrating NumPy in a better way with Cython. What we ended
up with is that I will over the summer add Cython support for the Python 3
buffer interface:

http://wiki.cython.org/enhancements/buffer

(We aim to support NumPy back to Python 2.3, perhaps as a special case,
but the buffer interface will guide in what way we support it.)

General feedback is welcome; in particular, I need more opinions about
what syntax people would like. We seem unable to find something that we
really like; this is the current best candidate (cdef is the way you
declare types on variables in Cython):

cdef int i = 4, j = 6
cdef np.ndarray[np.float64, 2] arr = np.zeros((10, 10), dtype=np.float64)
arr[i, j] = 1
...

The code above the under the hood acquires a buffer and uses it for
efficient access. arr[5], arr[5,6,7], arr[2:4,...] and in general anything
but two simple indices will be passed to Python, while arr[i, j] will be
passed to the buffer.

This is a natural first step and I'll focus on this exclusively in the
beginning.

(That said, once this is in place, there are of course lots of
opportunities of doing an even better job in supporting the numerical
community with Cython: ndenumerate, more efficient buffer acquisition and
array creation, more efficient calling of NumPy/SciPy functions without
going through the Python "calling convention", etc..)

Dag Sverre

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to