News for hackers. Stuff that matters.
Re:No-GIL mode coming for Python by n2d4 on Friday July 28, 2023 @08:54PM (#36915581)
It's only about performance. asyncio is still inherently single-threaded, and hence also single core. multiprocessing is multi-core and hence better for performance, but each process is relatively heavy and there's additional overhead to shared memory. GIL multi-threading is both single-core and difficult to use correctly.

No-GIL multi-threading is multi-core, though difficult to use. I don't know the Python implementation but shared memory should be faster than using multiprocessing.

That said, when designing a system from scratch, I completely agree with you that for almost almost almost all Python use cases, threads should never be touched and asyncio/multiprocessing is the way to go instead. Most Python programs that need fast multi-threading instead should not have been written in Python. Still, we're here now and people did write CPU-intensive code in Python for one reason or another, so no-GIL is practical.

In these threads, I also always see a lot of people who simply aren't aware of asyncio/multiprocessing. I assume these are also a significant share of people asking for no-GIL, though probably not the ones pushing the change in the committee.

Re:No-GIL mode coming for Python by slt2021 on Friday July 28, 2023 @08:59PM (#36915610)
I would argue that if you have large concurrency and shared complex state - you better off use kafka and redis/memcached as a shared state - and design proper fan-out.

This design scales much better for systems that will eventually overgrow one big machine. the No-GIL pytohn will be of no use, when you need to deploy your app across 100s machines.

I understand people want to take advantage of all cores etc, but at large scale - you will eventually need to split computation across machines and will resort to in-memory cache/queue anyways - so better just architect your system since day0

Re:No-GIL mode coming for Python by whalesalad on Friday July 28, 2023 @09:41PM (#36915899)
sometimes you need all of that data in-process. when you move that state into redis, you still need to perform i/o to access it. when speed matters, this is troublesome.
Re:No-GIL mode coming for Python by n2d4 on Friday July 28, 2023 @09:19PM (#36915739)
Stores like that, while scaling well, are orders of magnitudes slower than CPU memory. The kind of application I was thinking of is more compute-intensive, eg. image processing or fancy algorithms.
Re:No-GIL mode coming for Python by pxeger1 on Saturday July 29, 2023 @02:01AM (#36917377)
But many systems will never need to run at that kind of scale, but could still benefit from better threading performance, so it's good to have an "intermediate" choice, if that's what you consider it.
Re:No-GIL mode coming for Python by AlphaSite on Saturday July 29, 2023 @02:56AM (#36917626)
There are a lot of performance sensitive codebases where something like this would destroy performance, it works well for shared nothing parallelism, but the moment you have shared state it kinda falls over.
Re:No-GIL mode coming for Python by lozenge on Saturday July 29, 2023 @04:35AM (#36918181)
PostgreSQL shows how far you can get with a single big box and using multiple cores and shared memory. It's incredibly powerful and the vast majority of applications never have data big enough to warrant "100s of machines".
Re:No-GIL mode coming for Python by merb on Saturday July 29, 2023 @05:09AM (#36918352)
and even they are looking into changing its shared memory and process model to work and make it multi-threaded: https://www.postgresql.org/message-id/flat/31cc6df9-53fe-3cd...

probably a way more problematic effort than no gil python tough and it might fail

Re:No-GIL mode coming for Python by mrkeen on Saturday July 29, 2023 @10:36AM (#36920733)
> you will eventually need to split computation across machines

More machines is a multiplier. Instead of underutilising 1 machine, you'll be underutilising 100s of machines. More incentive to remove locking.

Re:No-GIL mode coming for Python by KeplerBoy on Saturday July 29, 2023 @02:43AM (#36917570)
Even with multithreading Python will still be slow. It's not like singlethreaded Python can keep up with singlethreaded C or even JS.

This will just allow people to waste even more compute resources to get somewhat quick results from Python instead of doing the right thing.

From an ecological viewpoint this PEP will be disastrous and keep entire power plants online.

Re:No-GIL mode coming for Python by BiteCode_dev on Saturday July 29, 2023 @03:22AM (#36917757)
Do you include the man hours in those calculations? Because they pollute a lot between the car, the food, the electricity the computer and internet for devs consumes, etc.
Re:No-GIL mode coming for Python by AlphaSite on Saturday July 29, 2023 @02:55AM (#36917620)
Python is also getting a JIT, they’re pursuing performance on all axis.
Re:No-GIL mode coming for Python by tjpnz on Saturday July 29, 2023 @02:52AM (#36917606)
The text editors people use to write said code will keep even more power plants online.
Re:No-GIL mode coming for Python by miraculixx on Saturday July 29, 2023 @04:48AM (#36918253)
Especially PyCharm with its endless indexing. Have the time its key features are not available bc it has decided to go on another indexing spree. Alas that's for another thread ;)
Re:No-GIL mode coming for Python by hanselot on Saturday July 29, 2023 @03:12AM (#36917712)
Sometimes the right thing is writing code in a language that reaches market before runway runs out.
Re:No-GIL mode coming for Python by dgb23 on Saturday July 29, 2023 @03:54AM (#36917932)
Ecosystem churn and exposing more issues to python contradicts this.

The whole point of using languages like python, js etc. is to not worry about whole classes of problems and intricacies.

There are modern languages with great tooling like Go, Rust or Clojure that have excellent support for safe concurrency and parallel execution etc.

And there are reliable, well established languages like Java/C# that have been doing this forever.

Re:No-GIL mode coming for Python by miraculixx on Saturday July 29, 2023 @04:48AM (#36918245)
This. Python had a unique stance, it was different for a good reason.

The seamingly endless attempt to become more likeable to yet another subgroup of needs is not a good development. It started with static typing, it continued with async, and now we have free threading as the final draw.

Re:No-GIL mode coming for Python by KeplerBoy on Saturday July 29, 2023 @03:56AM (#36917946)
That's fine for regular Python, but this doesn't convince me for multithreaded Python. Most Python modules which are optimized for performance (numpy, pytorch, pandas, and all others built on top of them) are already multithreaded and drop the GIL so you can parallelize your workload with the threading module.

If someone really needs several threads of pure python being interpreted, something is afoul imo.

Re:No-GIL mode coming for Python by geekraver on Saturday July 29, 2023 @02:52PM (#36923275)
A free-threaded Python will be harder to make faster for single-threaded cases. So this could be a win for those who want to write multi-threaded code at the expense of everyone else.
Re:No-GIL mode coming for Python by chippiewill on Monday July 31, 2023 @02:48PM (#36947112)
> asyncio is still inherently single-threaded, and hence also single core.

IIRC some of the proposals around removing the GIL in the past have actually suggested that the asyncio paradigm could become multithreaded for parallelism.