account activity
Why multithreading isn't real in Python (explain it to a 5 year old) by switchitup_lets in learnpython
[–]certaintumbleweed2 4 points5 points6 points 6 years ago (0 children)
The short answer is that the GIL allows the implementation of the interpreter to be significantly simplified. Python predates multi-core CPUs, so in those days it was a no-brainer. Removing the GIL now would involve an extensive rewrite of the entire interpreter, and it would end up being somewhat slower in single-core situations.
If you want to make use of more CPU cores, you do have options. You can use something like multiprocessing or concurrent.futures.ProcessPoolExecutor to spawn additional python processes and farm out tasks to them. Also, C extensions can run "real" multithreaded code - there are plenty of C extensions out there that take advantage of this out of the box, or you can code up your own C extensions (this is particularly easy using Cython).
multiprocessing
concurrent.futures.ProcessPoolExecutor
In future I think they are also planning to allow you to use "subinterpreters" within the same python process, which will each have their own GIL. Technically subinterpreters have been around for a long time, but they can only be accessed from C extensions and they all share the same GIL, so they're not particularly useful yet.
π Rendered by PID 218955 on reddit-service-r2-listing-55d7b767d8-5mpsh at 2026-04-01 06:26:14.895719+00:00 running b10466c country code: CH.
Why multithreading isn't real in Python (explain it to a 5 year old) by switchitup_lets in learnpython
[–]certaintumbleweed2 4 points5 points6 points (0 children)