On Jun 9, 2009, at 1:46 AM, Dag Sverre Seljebotn wrote:

> Robert Bradshaw wrote:
>>> Hmm. I'm not against that -- would you then be ok with
>>>
>>> cdef int[:] foo
>>>
>>> not giving any object access at all? (The thing is I also want to
>>> use it
>>> to access arrays stored in C pointers etc.; + safe passing around of
>>> buffers in nogil mode!)
>>
>> I could accept that, I trust that the details could be worked out
>> nicely. Would be like a char* from an object, where the user is
>> required to keep the object around long enough?
>
> With C pointers, yes. With buffers acquired from Python objects it  
> would
> hold a reference, but I was thinking only acquisition/release would
> require GIL. I.e.
>
> cdef int[:] a = obj # requires GIL
> cdef int[:] b = a # does not require GIL -- extra "acquisition count"
> # (remember that acquisition does have a speed penalty too, that
> # really must go if one wants to use efficient slices inside
> # numeric loops)
>
> In some very contrived cases a release could be needed within a nogil
> block though...there are ways to resolve that (release queues or
> reacquiring the GIL temporarily). But users are unlikely to produce  
> code
> requiring it.

This sounds like a very good use case, and perhaps one could even  
assign (with a cast?) raw c pointers to it too (or maybe I'm being  
too ambitious there).

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to