News for hackers. Stuff that matters.
Re:Data races in Python, despite the Global Interpreter Lock by chrisseaton on Monday February 21, 2022 @06:20PM (#30422051)
The semantic operation is increment. It being read, add, write is an implementation detail. The increments happen simultaneously, meeting the definition for 'data race' according to Padua, which is the definition most people would use.

https://link.springer.com/referenceworkentry/10.1007/978-0-3...

Re:Data races in Python, despite the Global Interpreter Lock by Kranar on Monday February 21, 2022 @07:29PM (#30422647)
Your link doesn't say anything about data races, it's a link to race conditions which are not the same thing as data races.
Re:Data races in Python, despite the Global Interpreter Lock by chrisseaton on Monday February 21, 2022 @07:32PM (#30422682)
> Your link doesn't say anything about data races

Under the section 'General Races and Data Races', then 'Data race'. There's a definition of data races, in relation to general races.

"A data race is a special case of a general race. A data race exists between conflicting memory accesses..."

Re:Data races in Python, despite the Global Interpreter Lock by rkeene2 on Monday February 21, 2022 @08:39PM (#30423105)
The two semantic operations are increment then store.
Re:Data races in Python, despite the Global Interpreter Lock by chrisseaton on Monday February 21, 2022 @08:46PM (#30423148)
That's an implementation detail based on a particular architecture. A different architecture could have an atomic increment operation if it wanted to, and Python could use it for this syntax.
Re:Data races in Python, despite the Global Interpreter Lock by squeaky-clean on Monday February 21, 2022 @11:23PM (#30423953)
In Python though, there's really only one architecture. Yes there's PyPy and such, but CPython and it's bytecode is both the official implementation and official spec of Python. Maybe the underlying hardware has those operations, but the Python VM does not.
Re:Data races in Python, despite the Global Interpreter Lock by Thorrez on Tuesday February 22, 2022 @01:53AM (#30424750)
>The semantic operation is increment.

Why? Who defines that?

Re:Data races in Python, despite the Global Interpreter Lock by chrisseaton on Tuesday February 22, 2022 @04:54AM (#30425941)
Because that's what the user wrote. You can reason about the operation in terms of smaller operations (such as read, add, store) but not more coarse operations, because the user could have just written the single operation.
Re:Data races in Python, despite the Global Interpreter Lock by Thorrez on Thursday February 24, 2022 @12:58AM (#30451001)
Consider the situation "counter = counter + get_value()". That also can be reasoned about in terms of smaller operations, but not more coarse operations, because the user could have just written the single operation.

We wouldn't expect this to be atomic, because the get_value() function could do tons of things, and we don't expect all that to be atomic. It doesn't make sense to call something atomic just because the user wrote it.