by miraculixx · 3y ago · 0 comments
Yes it does. Unless we mean something different?
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.
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.
The changes to the GIL don't force the average user to write threading code.