News for hackers. Stuff that matters.
Re:No-GIL mode coming for Python by usrbinbash on Saturday July 29, 2023 @06:21AM (#36918704)
> Yes it does.

No, it doesn't.

    def thread_function():

        # thread may lose core here
        value = store.get_value() # or anywhere inside get_value

        # or here
        update(value) # or anywhere inside update()

        # or here
        store.put_value(value) # or anywhere inside put_value()
The GIL only makes certain internal functionality atomic. It doesn't protect the implemented logic from causing a race condition.

So unless I protect store with a lock, I can already get a race condition, GIL or no GIL.

Re:No-GIL mode coming for Python by csmpltn on Saturday July 29, 2023 @09:49AM (#36920305)
The user you're replying to is saying that the GIL is preventing multiple threads from executing Python bytecodes at once (preventing some classes of race conditions and ensuring thread safety). They are absolutely correct.

The GIL doesn't solve or prevent all classes of race conditions (which can stem from complex interactions with databases, the filesystem, etc). Removing the GIL though, will only make things worse from that perspective - making the language more difficult to work with (for non-technical people).

This is exactly why Python should be further simplified, and not made more complex - given the population which uses it most.

Re:No-GIL mode coming for Python by usrbinbash on Saturday July 29, 2023 @11:42AM (#36921349)
> and not made more complex

The changes to the GIL don't force the average user to write threading code.