[Numpy-discussion] Fast threading solution thoughts

Brian Granger ellisonbg.net@gmail....
Thu Feb 12 14:58:31 CST 2009


> 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

Yep, that would be fantastic!!!  While it doesn't make the code
multithreaded, having this sure would make it easy to get code ready
for multithreading

> 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.

Great, I will watch this.  I am more than willing to test this as well
as it is something I would use often.

Cheers,

Brian


More information about the Numpy-discussion mailing list