Earlier quoted context omitted.
Disabling the GIL can unlock true multi-core parallelism for multi-threaded programs, but this requires code to be restructured for safe concurrency, which isn't that difficult it seems: > When we found out about the “nogil” fork of Python it took a single person less than half a working day to adjust the codebase to use this fork and the results were astonishing. Now we can focus on data acquisition system developme…
>We frequently battle issues with the Python GIL at DeepMind. In many of our applications, we would like to run on the order of 50-100 threads per process. However, we often see that even with fewer than 10 threads the GIL becomes the bottleneck. To work around this problem, we sometimes use subprocesses, but in many cases the inter-process communication becomes too big of an overhead. To deal with the GIL, we usuall…
gh-116167: Allow disabling the GIL
71–80 of 259 posts
Re: gh-116167: Allow disabling the GIL
#72Earlier quoted context omitted.
I wish I had your optimism. Thoughtless bandwagon-y "criticism" is extraordinarily persistent.
There's no need to pretend Python has virtues which it lacks. It's not a fast language. It's fast enough for many purposes, sure, but it isn't fast, and this work is unlikely to change that. Fast er , sure, and that's great.
Working with threads is a pain in Python. If you want to spawn +10-20 threads in a process, it can quickly become way slower than running a single thread.
Removing the GIL and refactoring some of the core will unlock levels of concurrency that are currently not feasible with Python. And that's a great deal, in my opinion. Well worth the trouble they're going through.
Re: gh-116167: Allow disabling the GIL
#73Earlier quoted context omitted.
`multiprocessing` works fine for serving HTTP requests or do some other subset of embarrassingly-parallel problems.
> `multiprocessing` works fine for serving HTTP requests Not if you use Windows, then it's a mess. I have a suspicion that people who say that the multiprocessing works just fine never had to seriously use Python on Windows.
Re: gh-116167: Allow disabling the GIL
#74Earlier quoted context omitted.
How do single-threaded programs benefit from a lack of GIL?
Speed. Admittedly not quite as much so the way this patch is implemented, since it just short circuits the extra function calls, doesn’t omit them entirely.
Re: gh-116167: Allow disabling the GIL
#75Re: gh-116167: Allow disabling the GIL
#76I've been programming in Python for over 6 years now and every week I learn something new. But recently I've been thinking about moving to a more capable language with proper concurrency for backend API requests (FastAPI sucked). I also want types, so Elixir is not in the picture. I dabbled in Rust a bit. Although I was able to get the hang of things and build a CLI tool pretty quickly, I'm worried I'll have to deal…
What sucked about FastAPI?
Re: gh-116167: Allow disabling the GIL
#77Earlier quoted context omitted.
Notably, all of those are static languages and none of them have array types as nice as PyTorch or NumPy, among many other packages in the Python ecosystem. Those two facts are likely closely related.
If only there were a dynamic language which performs comparably to C and Fortran, and was specifically designed to have excellent array processing facilities. Unfortunately, the closest thing we have to that is Julia, which fails to meet none of the requirements. Alas.
Re: gh-116167: Allow disabling the GIL
#78While the title is correct, it is a bit misleading, because disabling the GIL breaks the asyncio tests. It's like saying the engine can be removed from my car. Sure, it can, but the car won't work.
Re: gh-116167: Allow disabling the GIL
#79A great video tour of the GIL - https://www.youtube.com/watch?v=Obt-vMVdM8s
Re: gh-116167: Allow disabling the GIL
#80I've been programming in Python for over 6 years now and every week I learn something new. But recently I've been thinking about moving to a more capable language with proper concurrency for backend API requests (FastAPI sucked). I also want types, so Elixir is not in the picture. I dabbled in Rust a bit. Although I was able to get the hang of things and build a CLI tool pretty quickly, I'm worried I'll have to deal…