News for hackers. Stuff that matters.
Re:Free-threaded CPython is ready to experiment with by MBCook on Friday July 12, 2024 @06:09PM (#40949913)
But it would give you more headroom before rewriting for performance would make sense right? That alone could be beneficial to a lot of people.
Re:Free-threaded CPython is ready to experiment with by rty32 on Friday July 12, 2024 @07:27PM (#40950403)
I think it is beneficial to some people, but not a lot. My guess is that most Python users (from beginners to advanced users, including many professional data scientists) have never heard of GIL or thought of doing any parallelization in Python. Code that needs performance and would benefit from multithreading, usually written by professional software engineers, likely isn't written in Python in the first place. It would make sense for projects that can benefit from disabling GIL without a ton of changes. Remember it is not trivial to update single threaded code to use multithreading correctly.

in Python language specifically. Their library may have already done some form of parallelization under the hood

Re:Free-threaded CPython is ready to experiment with by bdd8f1df777b on Saturday July 13, 2024 @12:09AM (#40951702)
> Code that needs performance and would benefit from multithreading, usually written by professional software engineers, likely isn't written in Python in the first place.

There are a lot of simple cases where multi-threading can easily triple or quadruple the performance.

Re:Free-threaded CPython is ready to experiment with by Certhas on Saturday July 13, 2024 @08:14AM (#40953626)
But multiprocessing can't?

I used to write a ton of MPI based parallel python. It's pretty straightforward. But one could easily imagine trying to improve the multiprocessing ergonomics rather than introducing threading. Obviously the people who made the choice to push forward with this are aware of these options, too. Still mildly puzzling to me why threads for Python are needed/reasonable.

Re:Free-threaded CPython is ready to experiment with by pdhborges on Saturday July 13, 2024 @04:48PM (#40956764)
It doesn't to be puzzling just read the motivation section of https://peps.python.org/pep-0703/
Re:Free-threaded CPython is ready to experiment with by Certhas on Sunday July 14, 2024 @09:03AM (#40960719)
I know that document. It doesn't really answer this point though. It motivates the need for parallelism in slow python by noting that this is important once other performance critical code is in extensions.

But the mai point against multiprocessing seems to be that spawning new processes is slow ...

That single "alternatives" paragraph doesn't answer at all why mp isn't viable for python level parallelism.

I am no longer invested in python heavily, I am sure there are discussions or documents somewhere that go into this more. Might be that it's simply that everyone is used to threads so you should support it for sheer familiarity. All I am saying is it's not obvious to a casual observer.

Re:Free-threaded CPython is ready to experiment with by bdd8f1df777b on Friday July 19, 2024 @09:53AM (#41006617)
A common pain point for me is parallel data loading and processing for PyTorch or TensorFlow. Multiprocessing has a lot of bugs and pain points to deal with when doing ML. Examples: https://github.com/search?q=repo%3Apytorch%2Fpytorch+multipr.... Most of these issues do not exist in a multithreading world, because resource sharing is trivial in that case.

Since Python leads over any other languages in the ML community, and ML is a hot topic right now, it makes sense for Python developers to secure the lead by making the life of ML developers easier, which is by introducing GIL-less multi-threading.