News for hackers. Stuff that matters.
Re:Data races in Python, despite the Global Interpreter Lock by Thorrez on Tuesday February 22, 2022 @01:41AM (#30424694)
As reitzensteinm points out, even if every thread does "x = x + 1", x can decrease.

x starts as 0.

Thread A evaluates x + 1, getting 1.

Thread B executes the full statement 100 times, setting x to 100.

Thread A finishes executing the statement, setting x to 1.

So x decreased from 100 to 1.

But I agree with you that this is a race condition, not a data race.

There are no comments on this comment yet.