is +=1 thread safe

Carl Banks pavlovevidence at gmail.com
Sun May 4 14:25:36 EDT 2008


On May 4, 2:13 pm, Carl Banks <pavlovevide... at gmail.com> wrote:
> However, what I said was not wholly untrue: code in C extensions is
> protected by the GIL and thus not interruptable, unless it either
> releases the GIL, or calls back into Python code (which is apparently
> what numpy scalars do).

And, because I know that someone will be nitpicky: yes, technically it
is interruptable at that point, but other Python threads trying to
execute the same piece of code are not allowed to run.


>     print 'final count:', count

This should be "int(count)".


Carl Banks



More information about the Python-list mailing list