Comment

Comment by tomp

Python’s GIL does exactly nothing to prevent data races (or any other concurrency issues); it merely protects the runtime from memory corruption stemming from concurrency.

Obviously, the fundamental issue with concurrency is programmer’s intent. This statement:

    x += 1; y -= 1
can be interpreted in two ways:

    atomic {
      x += 1
      y -= 1
    }
or

    atomic { x += 1 }
    atomic { y -= 1 }
The best the compiler can do would be to alert the programmer of the ambiguity; I know of no compiler that does that.
parent tomp 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton