Re:Python Language Summit: Python Without the GIL
by Areading314 on Thursday May 12, 2022 @12:04AM
(#31349159)
wouldn't removing the GIL cause all sorts of sudden race conditions and regressions in existing python code? I think there is a valid argument to keeping the GIL just for simplicity's sake
[ Parent
| on HN ]
Re:Python Language Summit: Python Without the GIL
by bratao on Thursday May 12, 2022 @12:12AM
(#31349198)
From my understanding, race conditions already exists today as the GIL is made to protect the internal Python structures. It only made it appears more infrequently.
Re:Python Language Summit: Python Without the GIL
by masklinn on Thursday May 12, 2022 @12:35AM
(#31349341)
> It only made it appears more infrequently.
It makes some operations atomic which is quite relevant.
Re:Python Language Summit: Python Without the GIL
by MrJohz on Thursday May 12, 2022 @12:56AM
(#31349459)
Fewer than people expect. For example, the += operator looks atomic, but under the hood, it's made up of multiple python bytecode instructions, so the GIL won't apply here.
Re:Python Language Summit: Python Without the GIL
by masklinn on Thursday May 12, 2022 @06:46AM
(#31352033)
> For example, the += operator looks atomic, but under the hood, it's made up of multiple python bytecode instructions, so the GIL won't apply here.
Sure, but any call to a native function which doesn’t release the gil (which is most of them at least for the builtins) is currently atomic so something like dict.setdefault.
Re:Python Language Summit: Python Without the GIL
by dontlaugh on Thursday May 12, 2022 @12:15PM
(#31356239)
Those would have to remain atomic by taking explicit more granular locks.
Re:Python Language Summit: Python Without the GIL
by masklinn on Thursday May 12, 2022 @12:21PM
(#31356306)
Obviously?
But the point is currently they do work, they are thread-safe and they are correct in the strictest sense of the word, per-FAQ: https://docs.python.org/3/faq/library.html#what-kinds-of-glo...
So as the original commenter notes:
> wouldn't removing the GIL cause all sorts of sudden race conditions and regressions in existing python code?