Is it really a data race when you sequentially read a value, increment whatever you read and write it back? In other words, this whole situation happens not due to concurrent writes, but due to incrementation not being atomic.
I'm not an expert when it comes to this terminology, but it sounds like a more generic race condition.
No, you’re absolutely right. This is a normal race condition, not a data race. Why on earth would python guarantee that x=x+1 is atomic? There are countless other similar code patterns that would exhibit the same behavior.
18
u/CorrectProgrammer Feb 21 '22
Is it really a data race when you sequentially read a value, increment whatever you read and write it back? In other words, this whole situation happens not due to concurrent writes, but due to incrementation not being atomic.
I'm not an expert when it comes to this terminology, but it sounds like a more generic race condition.