Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is this true? It looks like += compiles to four bytecode instructions: two loads, an increment, and a store. It should be possible for a thread to get paused after the load but before the store, resulting in a stale read and lost write.

Some more discussion here: https://stackoverflow.com/questions/1717393/is-the-operator-...



With the GIL, for an int i, `i += 1` is not thread-safe, but IIRC for a list l, `l += [1]` (i.e. extend) is.

Presumably this patch changes the list implementation in some way so that the extend operation remains thread-safe without the GIL.


Maybe it's just certain collection operations, then.


And the proposal clearly addresses adjusting those to maintain the expected guarantees.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: