Live data from Hacker News

Intent to approve PEP 703: making the GIL optional

discuss.python.org

441–450 of 513 posts

Re: Intent to approve PEP 703: making the GIL optional

#441

Earlier quoted context omitted.

> I never said that multiprocessing is "better" than multithreading. Maybe not, but you seem to be implying that multiprocessing is a sufficient for the most case (or the average case ?) however ill define that average case is. > This conversation would've been much easier to have given specific constraints and examples (which nobody seems to give). Not quite, there is no need grand example here, processes vs threads…

> "there is no need [for a] grand example here" > "you don't get to decide in the abstract what the right tool is for other people and context we don't know anything about" So which one is it? Do I get to ask for concrete examples for why this work is worth all the trouble, or should we just pretend like it doesn't matter because you say so? "I want threads, threads fast, others have threads" is not good enough. > "s…

> So which one is it? Do I get to ask for concrete examples for why this work is worth all the trouble, or should we just pretend like it doesn't matter because you say so?

Both ?

1 - There is no need for a grand example to justify the need for threading in a modern language, as we have 20/30 years of background on that topic. To repeat myself, it's all about the amount of communication between compute agent... The more communication you have , the more the process isolation/serialization cost become a problem.

2 - You yourself understand that there is are valid use case for threading, somehow those valid cases are not valid python uses. That's where the disconnect is. You don't get to say by decree what is and is not a "valid" use of python.

> "I want threads, threads fast, others have threads" is not good enough.

Neither is i don't use thread , you shouldn't use thread.

> CPython has had a GIL for the past 30 years - and things worked out just fine.

That's what the no-gil people are trying to tell you, no it's not fine and it was never fine. Effort and conversation about the replacement of the GIL are at least 10/15 years old.

> yet CPython remains the most widely used and popular VM Faulty logic , the correlation doesn't imply any causal relationship.

> and start actually justifying the asks beyond hand-waving my arguments away?

Because you aregument are not really argument, they more like strong opinion on things that are closer to esthetics and right/wrong usage of things. Happy to disagree on those one.

> There's a clear difference between building an ecosystem with multithreading in mind from day one - and suddenly introducing it out of nowhere, 30 years into it being used by millions of workloads globally.

1 - no-gil isn't out of nowhere. Conversation about this are more that 10 years old. Combined with even longer conversation in other VM/programming language.

2 - no-gil doesn't introduce threading in random workload. It allow people who want threading to use threading.

> This is why I'm asking for "qualifications"

It's your prerogative to ask for qualifications. But it's also our to decide to judge your ask and decide if they are worth our time.

Much in the same way that if feel like we don't need (in 2023) a grand example to justify why we need to add a type system, we don't need a deep conversation about threading. We all have the same information, understand the trade-off. We just have different value system and want different things out of python. And that's okay...

> the problem is not that deep" to be a proof beyond any that we should end this conversation now before things get too embarrassing for you :)

I think i have some comment somewhere explaining why no-gil was never a technically challenging problem. But the prof is simple... Sam Gross is definitely an exceptional dev, but the fact that a lone programmer come out with an acceptable solution is proof that the problem wasnt that deep.

Re: Intent to approve PEP 703: making the GIL optional

#442

Earlier quoted context omitted.

> Yes it does. No, it doesn't. def thread_function(): # thread may lose core here value = store.get_value() # or anywhere inside get_value # or here update(value) # or anywhere inside update() # or here store.put_value(value) # or anywhere inside put_value() The GIL only makes certain internal functionality atomic. It doesn't protect the implemented logic from causing a race condition. So unless I protect store with…

The user you're replying to is saying that the GIL is preventing multiple threads from executing Python bytecodes at once (preventing some classes of race conditions and ensuring thread safety). They are absolutely correct. The GIL doesn't solve or prevent all classes of race conditions (which can stem from complex interactions with databases, the filesystem, etc). Removing the GIL though, will only make things worse…

> and not made more complex

The changes to the GIL don't force the average user to write threading code.

Re: Intent to approve PEP 703: making the GIL optional

#443
post #33

Lots of C library code for decades carried man page warnings it was unstable for use in async, re-entrant and recursive contexts. We learned how to cope and incrementally re-entrant safe versions deployed without too much API instability. Maybe time has healed wounds and caused me memory loss of the pain of discovery you'd tripped over them. String parsing which tokenised in-place. DNS calls which used static buffers…

That can't stay forever.

We're now up to 128 core CPUs, and even cheap CPUs have 6 cores on them. Restricting things to a single core's performance gets more and more limiting as time passes.

Re: Intent to approve PEP 703: making the GIL optional

#444

Earlier quoted context omitted.

> I never said that multiprocessing is "better" than multithreading. Maybe not, but you seem to be implying that multiprocessing is a sufficient for the most case (or the average case ?) however ill define that average case is. > This conversation would've been much easier to have given specific constraints and examples (which nobody seems to give). Not quite, there is no need grand example here, processes vs threads…

> "there is no need [for a] grand example here" > "you don't get to decide in the abstract what the right tool is for other people and context we don't know anything about" So which one is it? Do I get to ask for concrete examples for why this work is worth all the trouble, or should we just pretend like it doesn't matter because you say so? "I want threads, threads fast, others have threads" is not good enough. > "s…

> CPython has had a GIL for the past 30 years - and things worked out just fine.

No, they did not.

That's why the discussion about the GIL is about as old as Python3 itself.

The GIL has always been a major drawback of python, moreso because the language does in fact have threading support...only it can't use threads for parallel workloads.

This drawback was tolerated, because of the many advantages Python brings to the table, and because Python comes from an age when Moores Law was still in full effect; Powerful single cores were the norm not so long ago.

This isn't the case any more. Moores Law is done. Now we increase the number of cores, and languages that wish to remain relevant, need to reflect that.

Re: Intent to approve PEP 703: making the GIL optional

#445

Earlier quoted context omitted.

> There are no good answers afaik. I shall be more than happy to provide them: Supporting thread based parallelism is the norm among all mainstream PLs with the one inglorious exception of JS, which doesn't because it simply can't. And Python already does support it, it simply is limited by a legacy design decision. That was okay in a bygone age when fast single core machines were still the norm, Python was primarily…

> because it simply can't. It can't for the same reason python can't - every part was designed without it in mind. > Python already does support it The language runtime might have it in a branch, but the vast majority of C code it is based on, and the scripts themselves assume otherwise. > fast single core machines Once again, if you are using python as a scripting language, with C libraries, and spawning processes,…

> every part was designed without it in mind.

Interesting, care to explain then why Python supported threading since Python2? [1]

> Once again, if you are using python as a scripting language

> If that's true, then you shouldn't use python.

Once again, I don't. I use it as an orchestration language calling other code, and there is no good reason why the orchestration language should have an arbitrary bottleneck.

Yes, the hot code isn't written in Python. That doesn't matter to this discussion.

> In the "web application" example you are using, the norm is already to have many processes to handle incoming connections.

Outside of the python world, it absolutely isn't. I also have numerous Go based webservices, and they don't have to jump through ICP hoops to facilitate communications between workers and services.

[1]: https://docs.python.org/2/library/threading.html

Re: Intent to approve PEP 703: making the GIL optional

#446

Earlier quoted context omitted.

Forking had a ton of its own downsides, it’s not a free lunch either, from poor ergonomics to communications overhead it works well for somethings and very poorly for others.

Yes, the same is true for free threading. Yet people assume free threading is free concurrency and that's the problem.

Show me someone who actually knows how threads work and what writing threading code entails who assumes that.

I am perfectly aware that threads are not free.

Just as I am perfectly aware that a context switch between threads is less expensive that switching a new process onto the core, and that IPC requires kernel involvement.

Re: Intent to approve PEP 703: making the GIL optional

#447

Earlier quoted context omitted.

> There are no good answers afaik. I shall be more than happy to provide them: Supporting thread based parallelism is the norm among all mainstream PLs with the one inglorious exception of JS, which doesn't because it simply can't. And Python already does support it, it simply is limited by a legacy design decision. That was okay in a bygone age when fast single core machines were still the norm, Python was primarily…

> "It's about time Python rids itself of that needless limitation." I want to correct one thing that I see plastered all over this thread. The GIL isn't a programming language construct. It's an implementation detail. The GIL isn't a "Python limitation" in any way, because it has nothing to do with Python. CPython (aka. Cython), probably the most popular and widely used VM for Python, was built around a GIL. There ar…

> It's an implementation detail.

It's an implementation detail of CPython. Which is by far the most common Python interpreter. And it limits parallelisation via threads in Python, a language that otherwise natively supports threading.

So yes, it IS a needless limitation.

Re: Intent to approve PEP 703: making the GIL optional

#448
post #33

Lots of C library code for decades carried man page warnings it was unstable for use in async, re-entrant and recursive contexts. We learned how to cope and incrementally re-entrant safe versions deployed without too much API instability. Maybe time has healed wounds and caused me memory loss of the pain of discovery you'd tripped over them. String parsing which tokenised in-place. DNS calls which used static buffers…

While I'm happy to see optional GIL approved and happening,

I also suspect that the GIL has saved us from debugging reentrant and/or dangerously concurrent code for years, and I salute the GIL for forcing us to build Arrow for IPC in Python, in particular.

Someday, URI attributes in CPython docstrings might specify which functions are constant time, non re-entrant, functions.

Reentrancy (computing): https://en.wikipedia.org/wiki/Reentrancy_(computing)

Global Interpreter Lock: https://en.wikipedia.org/wiki/Global_interpreter_lock

Re: Intent to approve PEP 703: making the GIL optional

#449
post #33

Lots of C library code for decades carried man page warnings it was unstable for use in async, re-entrant and recursive contexts. We learned how to cope and incrementally re-entrant safe versions deployed without too much API instability. Maybe time has healed wounds and caused me memory loss of the pain of discovery you'd tripped over them. String parsing which tokenised in-place. DNS calls which used static buffers…

What is Vax specific stack behaviour?

Re: Intent to approve PEP 703: making the GIL optional

#450

Earlier quoted context omitted.

But the python 2->3 migration has been exactly that

No cats were harmed in the migration from Python 2 to 3. Programmers and project managers on the other hand...

I would hope they're not hurting the cats that they're herding. That's pretty terrible shepherding
Post reply on HN