Hacker News new | ask | show | jobs
by fleetfox 693 days ago
If you are interested PEP703 describes the scenarios pretty well: https://peps.python.org/pep-0703/#motivation
1 comments

I just wrote a post about how the Cpython is much faster without GIL:https://news.ycombinator.com/item?id=40988244
I mean, only the threaded version, which is expected. For tons of cases Python without the GIL is not just slower, but significantly slower; "somewhere from 30-50%" according to one of the people working on this: https://news.ycombinator.com/item?id=40949628

All of this is why the GIL wasn't removed 20 years ago. There are real trade-offs here.

30-50% is an understatement. The latest beta is more than 100% slower in a simple benchmark:

https://news.ycombinator.com/item?id=41019626

How is single-threaded code slower without GIL?
Because in the --disable-gil build data structures like ref-counting, dicts, freelists, etc. are locked, even when there is only a single thread.

This is the reason why previous attempts were rejected. But those attempts came from single individuals and not from a photo sharing website.

This matters if --disable-gil becomes the default in the future and is forced on everyone.

That cannot be the reason for a 30-50% slowdown. Uncontested locks are very fast.
They may be fast in C++, but not in the context of CPython. Here are the dirty details. Note that fine-grained locking has also been tried before:

https://dabeaz.blogspot.com/2011/08/inside-look-at-gil-remov...