4 ms·
foo += 1 was never atomic. It always compiled to something like: LOAD_FAST foo LOAD_CONST 1 BINARY_OP + STORE_FAST foo The GIL only protected
by Jasper_ 3y ago
foo += 1 was never atomic. It always compiled to something like:
LOAD_FAST foo
LOAD_CONST 1
BINARY_OP +
STORE_FAST foo
The GIL only protected you during any of those operations, so you can still switch threads waiting between LOAD_FAST and STORE_FAST and have a race.
There are a lot of things to be worried about with the GIL conversion of new race conditions that could happen, but there's already too much misinformation out there about the GIL, let's not spread this one even further.