PEP 703 makes race conditions more likely, but in the general case it doesn’t introduce a risk that didn’t exist already.
I would contend that it does introduce a risk that didn’t exist already:
There are plenty of simple if that: do this checks in code that are safe with the GIL (whether accidentally or deliberately) that would be unsafe with FT.
But, you are right, the GIL isn’t magic.
If if’s “in the same way” as with the GIL, then ThreadGroup is affected by the issue explained above.
Threads within a ThreadGroup get GIL-like protection But ThreadGroups themselves get strong protection from race conditions. Not quite as strong as multiple interpreters, but close.
You can’t just serialize threads and then decide you have no synchronization to care about.
True, but we already have the GIL. We can’t just throw it away and pretend that nothing will break.
We want to add parallelism, not lessen safety.
This seems to favour task-based parallelism rather than data-based parallelism
Can you more specific about how you are distinguishing the two, and why you think that is?
If by data-based parallelism, you mean operating on large arrays of numbers in parallel, that’s probably best left to numpy and friends.
The PEP explicitly discourages sharing mutable data. Parallel operations on mutable data can’t scale due to physical limitations, as well as being very easy to get wrong. Immutable can be shared among as many threads as you want, safely.
How is it possible to implement this in a Python implementation that doesn’t use reference counting?
With difficulty, but I have a fix for that. Watch this space…
This is neat, but orthogonal to this PEP, right?
Not orthogonal, not a core concept either, but a necessary add-on.
If the aim of the PEP is to enforce necessary locking and claim safety, we don’t want to be replacing races with deadlocks
Sure, but multi-threading bugs in collections have also existed in spite of the GIL. They just have been painfully squashed, one by one, along multiple decades.
There haven’t been that many, I think (largely due to the GIL). There have been plenty of re-entrancy bugs though, which do look similar.