is +=1 thread safe

Paul Rubin http
Fri May 2 03:28:40 EDT 2008


AlFire <spamgrinder.trylater at ggmail.com> writes:
> But I still can not believe that +=1 is not a thread safe operation.

In CPython I believe it is thread safe, because of the global
interpreter lock.  Thread switches can happen only between bytecode
executions, not in the middle of a bytecode, even though executing a
bytecode can take several machine instructions.



More information about the Python-list mailing list