3 ms·
it's kind of the canonical example of a data race. down in machine code land, the instructions that implement synchronization primitives are typically of the fo
by a-dub 5y ago
it's kind of the canonical example of a data race. down in machine code land, the instructions that implement synchronization primitives are typically of the form "check prior existing value and change the value in one atomic step."
and yes, as everyone is saying, the gil keeps the python interpreter/runtime from ending up in an inconsistent state... its behavior should not be depended on by user programs. if you need to increment a counter, use a lock, or a counter that explicitly states that it's a thread safe atomic counter on the tin.