Every single HN thread on python performance, ever:<p>Person with limited to zero experience with CPython internals> I hate the GIL, why don't they <i>just remove it</i>?<p>That <i>just</i> is doing an incredible amount of heavy lifting. It'd be like saying, "Why doesn't the USA <i>just</i> switch entirely to the metric system?" It's a huge ask, and after being burned by the 2/3 transition, the python team is loathe to rock to boat too much again.<p>The GIL is deep, arguably one of the deepest abstractions in the codebase, up there with PyObject itself. Think about having to redefine the String implementation of a codebase in your language of choice.<p>Whatever your monday-morning quarterback idea on how to pull out the GIL is, I can almost guarantee, someone has thought about it, probably implemented it, and determined it will have one or more side effects:<p>- Reduced single-thread performance<p>- Breaking ABI/FFI compatibility<p>- Not breaking ABI immediately, but massively introducing the risk of hard to track concurrency bugs that didn't exist before, because GIL<p>- Creating a maintenance nightmare by adding tons of complexity, switches, conditionals, etc to the codebase<p>The team has already decided those tradeoffs are not really justifiable.<p>The GILectomy project has probably come the closest, but it impacts single-thread performance by introducing a mutex (there are some reference type tricks [1] to mitigate the hit, but it still hurts run time 10-50%), and necessitates any extension libraries update their code in a strongly API-breaking way.<p>It's possible that over time, there are improvements which simultaneously improve performance or maintainability, while also lessening the pain of a future GILectomy, e.g. anything which reduces the reliance on checking reference counts.<p>[1] PEP 683 is probably a prerequisite for any future GILectomy attempts, which looks like it has been accepted, which is great <a href="https://peps.python.org/pep-0683/" rel="nofollow noreferrer">https://peps.python.org/pep-0683/</a>