Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork320
True thread parallelism with Python 3.12#442
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
For decades python developers have been trying to work around the infamousGlobal Interpreter Lock (aka GIL), which has been preventing true multi-threading. With modern CPUs having many CPU cores it is a terrible waste for python to be able to use only one at a time. Well, the time has come and Python 3.12 brings a breakthrough in this area. Subinterpreters was an obscure and rarely used feature of python, that allowed threads to run in clean slate environment. But they still had to acquire the GIL before they could run code. This is no longer with Python 3.12.Each subinterpreter may have its own GIL, which means they can run in parallel. Truly! This feature is not available in python code yet, but can be exploited using the C-API. It has also a number of limitations the most important of which are:
But despite these limitations, the performance boost that comes from the exploitation of multiple cores makes this feature very desirable. P4D has already added support for the new subinterpreters and has integrated that functionality within the TPythonThread. A new thread execution mode Here are the results of this demo on my machine demonstrating the performance boost you expect to get:
|
BetaWas this translation helpful?Give feedback.
All reactions
👍 1🎉 1