Sturla Molden wrote:
> On 3/6/2009 7:23 AM, Greg Ewing wrote:
>
>> You'd have to do quite a lot more than that. I don't
>> remember all the details,
>
> There is also the simplified GIL API, which only requires two function
> calls. This is e.g. how ctypes makes sure the GIL is held in callbacks
> to Python.
>
> A 'with gil' block could just expand to:
>
> {
>     PyGILState_STATE _gilstate = PyGILState_Ensure();
>
>     /* now we have the GIL */
>
>     PyGILState_Release(_gilstate);
> }
>
> Nothing else is required.

For pure C code, that might be true. However, in the current Pyrex/Cython
language (and in Python, BTW), function local variables are global to the
function and not local to a block. And supporting a "with gil" block would
require to restrict all ref-counting related operations (e.g. variable
initialisations and function cleanup) to the specific block that uses
them. That's the hard part.

Stefan

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

Reply via email to