[Cython] OpenMP support

Stefan Behnel stefan_ml at behnel.de
Wed Mar 9 06:26:40 CET 2011

Greg Ewing, 09.03.2011 00:27:
> Stefan Behnel wrote:
>> You *can* use Python references inside of nogil blocks, even if there's a
>> lot of stuff that you can't do with them, ... But you can access cdef
>  > attributes on them,
> Strictly speaking it's not even safe to do that, unless
> you know there's some locking mechanism in effect that
> prevents the underlying Python object going away from
> under you.

Right. It also depends on where the reference came from. If it's held by a 
local variable that entered a nogil block, it's safe to use the reference, 
because it cannot be deallocated inside of the nogil block. However, if it 
is in a closure or in an object attribute that other parts of the code have 
access to, they may choose to change the binding, thus potentially 
deallocating the reference.

Maybe Cython could do another tiny bit more here, e.g. issue a minor 
warning for potential concurrency problems like this, that users could 
enable in their test suites.


More information about the cython-devel mailing list