Brian Granger wrote:
> And a question:
>> With the new Numpy support in Cython, does Cython release the GIL if
> it can when running through through loops over numpy arrays? Does
> Cython call into the C API during these sections?
You know, I thought of the exact same thing when reading your post. No,
you need the GIL currently, but that's something I'd like to fix.
Ideally, it would be something like this:
cdef int i, s = 0, n = ...
cdef np.ndarray[int] arr = ... # will require the GIL
with nogil:
for i in range(n):
s += arr[i] # does not require GIL
The only Python operation needed on the last line is throwing an exception
if one is out of bounds; but I can always insert code to reacquire the GIL
in that exceptional case. (And in most cases like this the user will turn
off bounds-checking anyway.)
http://trac.cython.org/cython_trac/ticket/210 will contain progress on this.
Dag Sverre