News for hackers. Stuff that matters.
Re:Python Language Summit: Python Without the GIL by metadat on Wednesday May 11, 2022 @09:43PM (#31348235)
> “We need to lay out a plan of how to proceed,” remarked Pablo Galindo Salgado. “Just creating a PR with 20,000 lines of code changed is infeasible.”

One of the saddest things about popular open-source projects like Python is how inevitably the maintainers become worn down and jaded over time, due to constantly filtering and protecting Python from dumb or nonsensical ideas.

Then when something like this comes along, a true game changer, maintainers have no energy or goodwill left to collaborate on these infinitely important initiatives, like removing the dogdamn GIL. This is way more significant than everything I'm aware of that's happened since the birth of the language. All other things have been, trivial miuntiae in comparison.

It bears repeating: "everything else has been trivial minutiae in comparison to a GIL-ectamy for Python."

It cannot be understated, removing the GIL will be a HUGE deal for Python! It's an ugly wart which has existed for about 30 years, and nobody else has produced and delivered a working solution to the community.

I wish Team Python would welcome GIL Eradication with open arms and a supportive attitude. This would look like focusing on helping identify and implement solutions to the impediments rather than simply pointing out problems and then helicoptering away.

Re:Python Language Summit: Python Without the GIL by ctoth on Wednesday May 11, 2022 @11:06PM (#31348835)
> There was also a large amount of concern from the attendees about the impact the introduction of nogil could have on CPython development. Some worried that introducing nogil mode could mean that the number of tests run in CI would have to double. Others worried that the maintenance burden would significantly increase if two separate versions of CPython were supported simultaneously

The 2021 workstation I am typing this on has 16 physical and 32 virtual cores, and I expect core counts to continue upward this decade. While the CPython core devs may be excellent programmers and do a good job at maintaining Python, they clearly have a bit of trouble with cost/benefit analysis if the complaint is that the test count will double in CI for a ~16X increase in the amount of code that can be run in parallel on even consumer machines. Yes, yes, I know that this does not mean my programs will run ~16X as fast. Yes, I know there are other objections. But this is an order of magnitude away from being an actual blocker and the fact it was brought up at all as an objection shows a fundamental disconnect between the small potential costs imposed on core devs, and the huge potential upsides for Python users everywhere.

Re:Python Language Summit: Python Without the GIL by ben-schaaf on Thursday May 12, 2022 @03:02AM (#31350160)
> they clearly have a bit of trouble with cost/benefit analysis if the complaint is that the test count will double in CI for a ~16X increase in the amount of code that can be run in parallel on even consumer machines

You can already use multiple cores by writing C extensions that release the GIL and with multiprocessing. That double CI cost and additional work isn't just for core python but for the entire ecosystem.

Re:Python Language Summit: Python Without the GIL by coldtea on Thursday May 12, 2022 @04:46AM (#31350963)
>You can already use multiple cores by writing C extensions that release the GIL

I chose Python to not have to write C...

Re:Python Language Summit: Python Without the GIL by Too on Thursday May 12, 2022 @12:16PM (#31356253)
Let’s not forget that writing C extensions is the easy part.

The even more sucky part is to distribute them and make sure it works on every OS, without every user having to apt install build-utils before they can pip install your package and then spend rest of the day debugging some rare compilation error because of a header file mismatch with what’s installed on the system. The python packaging space is already complicated enough even without considering native modules.

Re:Python Language Summit: Python Without the GIL by sdmike1 on Thursday May 12, 2022 @03:47AM (#31350531)
The amount of additional complexity from a C extension is dramatic in any sort of Python application. and the performance hit from having to pickle all objects that you would like to share between processes when using multi-processing is significantly non-trivial.

True shared memory threads within a single process would be a major boon.

Re:Python Language Summit: Python Without the GIL by formerly_proven on Thursday May 12, 2022 @04:54AM (#31351032)
a) This only works for some applications and a very bad fit which does nothing for others. Namely, this only works if 1) you have few hot code locations 2) that code uses data structures which can be feasibly mogrified into native data structures with Python accessors 3) the granularity is low, meaning few invocations doing lots of work each. If any of these conditions aren't met, "native extensions invoked by Python threads" tends to be ineffective but maintenance-intensive.

b) Introducing native extensions means deployment and distribution becomes more difficult, and introduces a whole new and large class of issues and caveats into a project.

c) Native extensions are not written in Python. (Yes, Cython exists, no, it's usually not a good idea to write more than glue in it).

Re:Python Language Summit: Python Without the GIL by forrestthewoods on Thursday May 12, 2022 @03:34AM (#31350432)
> You can already use multiple cores by writing C extensions

Don’t use Python is also my preferred recommendation when I encounter Python.

Re:Python Language Summit: Python Without the GIL by andybak on Thursday May 12, 2022 @04:24AM (#31350785)
Thanks but:

1. Learning a new language is non-trivial for many people (and don't sneer - it's about time not competency)

2. The ecosystem matters. If the code you want to interface with is in Python then "don't use Python" is just glib.

I'm mainly proficient in Javascript, Python and C#. My choice of language is rarely based on "which is best for this task?" but mostly "want do I need to run on and interface with?"

Re:Python Language Summit: Python Without the GIL by anhner on Thursday May 12, 2022 @04:48AM (#31350975)
I think the person you replied to agrees with you, and was just being snark
Re:Python Language Summit: Python Without the GIL by gpderetta on Thursday May 12, 2022 @08:28AM (#31353024)
regarding point 1 if we are already at the point that you have to write a C extension to workaround language lossage, we can already assume you know C. At that point it is just easier to rewrite in another language that dealing with FFI.
Re:Python Language Summit: Python Without the GIL by staticassertion on Thursday May 12, 2022 @12:48PM (#31356616)
Or just don't write Python. There are a million languages without a GIL.
Re:Python Language Summit: Python Without the GIL by pfortuny on Thursday May 12, 2022 @08:20AM (#31352930)
This is exactly what Perl devs said… Or is your comment sarcasm?
Re:Python Language Summit: Python Without the GIL by omnicognate on Thursday May 12, 2022 @12:01PM (#31356049)
Not everybody agrees with you that it's a worthy goal. Personally I have little desire to see it removed, doubt its removal will be achieved and tend to think the various attempts to do it are misguided.

I could imagine getting pretty jaded as a python maintainer having to keep pointing out why the latest attempt won't work. I think the onus is on those who want this to demonstrate that it can be done successfully and lay out a plan as to how it can be put into the real world without causing chaos in a python ecosystem that has only relatively recently got over the trauma of python 3 (which is the bit I doubt is possible).

Edit: To be clear, I don't think anything that consists of a set of proposed changes to the cpython interpreter is even beginning to attempt to think about the implications for the ecosystem, which is where the actual challenges are, and I'm assuming that's what the "Just creating a PR" comment is saying.

Re:Python Language Summit: Python Without the GIL by Someone on Thursday May 12, 2022 @02:57AM (#31350123)
FTA: Overall, there was still a large amount of excitement and curiosity about nogil mode from the attendees.

⇒ I don’t see this as a team of worn-down maintainers, but rather as a team of seasoned developers, who know you don’t turn a project with millions of users around on a dime.

One question I miss is whether the set of locks this change introduces is the optimal one.

I would think that, if it were to be improved upon in the future, C extensions would have to be changed again, so you’d rather not do that often.

Re:Python Language Summit: Python Without the GIL by throwaway894345 on Thursday May 12, 2022 @06:15AM (#31351728)
> who know you don’t turn a project with millions of users around on a dime

Hasn’t this gil/nogil saga been going on for ~decades? What about fixing packaging or limiting the C-extension interface? I have enormous sympathy of what the Python maintainers are up against, but “on a dime” seems hard to justify.

Re:Python Language Summit: Python Without the GIL by mumblemumble on Thursday May 12, 2022 @09:42AM (#31354033)
Python nerfing C extensions would be like McDonald's deciding to de-emphasize burgers on their menu. Sure, other foods are healthier and get more positive buzz on Twitter. But it turns out that the burgers are still the main thing bringing people to the restaurant.
Re:Python Language Summit: Python Without the GIL by throwaway894345 on Thursday May 12, 2022 @10:04AM (#31354384)
I wasn’t talking about nerfing C-extensions. You can get the same power out of a smaller, well-defined interface that would give the interpreter a lot more leeway for optimization. This optimizations would therefore make native Python packages more feasible, making the ecosystem less dependent on C extensions. Anyway, I don’t think people use Python because of the C-extensions packages (although there are certainly some exceptions e.g., pandas), I think people use C extensions because the native performance is so poor.
Re:Python Language Summit: Python Without the GIL by pwang on Thursday May 12, 2022 @04:59PM (#31360070)
Over 50% of Python users report using it for data-related things, e.g. data science, ML, etc. (Jetbrains poll)

That's numpy, pandas, sklearn, and friends.

Re:Python Language Summit: Python Without the GIL by throwaway894345 on Thursday May 12, 2022 @09:09PM (#31362052)
Fair enough. I defer to JetBrains on that point.
Re:Python Language Summit: Python Without the GIL by fulafel on Saturday May 21, 2022 @02:35AM (#31455766)
This analogy is I think also favourable for the sea change: cecause we need to cut down on beef use due to climate reasons, and unless we plan to crash the climate, the end of bargain priced meat means that McDonalds needs to switch from meat to other kinds of burgers.
Re:Python Language Summit: Python Without the GIL by pmoriarty on Wednesday May 11, 2022 @10:21PM (#31348522)
"It cannot be understated, removing the GIL will be a HUGE deal for Python! It's an ugly wart which has existed for about 30 years, and nobody else has produced and delivered a working solution to the community."

If it's such a huge game changer why don't some of the large enterprises which rely on Python fund this work?

Re:Python Language Summit: Python Without the GIL by gorgoiler on Wednesday May 11, 2022 @10:49PM (#31348732)
Remember when it was discovered that arc welders could produce Carbon 60, and there was a huge run on arc welders? All of a sudden there was a whole new class of customer beyond the usual customer base of people who do welding: people who do materials science research.

I would hazard a guess to say that 99% of production Python is people doing the equivalent of welding, but there is also this 1% who want the GIL to be gone so they can repurpose Python as a tool for a whole new class of problem solving.

It will be an exciting future for them.

For us welders, we’ll carry on gluing stuff together blissfully unaware of the GIL. Async and non-blocking IO are great. I don’t think I’ve ever needed compute-concurrency, not in Python anyway.

Re:Python Language Summit: Python Without the GIL by m_mueller on Thursday May 12, 2022 @01:32AM (#31349641)
You may think you don’t need it but I suspect if you program larger than trivial python applications there comes a point where you do but you don’t even think about how the GIL is restricting you. Think about load time for example of something that does a bunch of work to initialise. Without the GIL it would be relatively trivial to speed up things that are independent, while with GIL you are usually out of luck because you can have either shared memory (e.g. previously loaded state) or concurrency but not both at the same time. From experience, trying to serialise and use multiprocessing is often eating up all the potential gains.
Re:Python Language Summit: Python Without the GIL by sgtnoodle on Thursday May 12, 2022 @03:13AM (#31350252)
I would love to parallelize a plugin script in Cura, the 3D print slicer. It does a bunch of embarrassingly parallel calculations, and could be made at least 16x faster for me. Because it's a plugin, though, it isn't pickle-able and multiprocessing doesn't work. I managed to make it work in a branch, but only on OSes that can fork processes. On windows, the plugin spawns multiple GUIs because importing the cura package apparently has the side effect of launching it...

If there wasn't the GIL, I could just create a thread pool and be done, and Cura could continue to be a delightful mess. :-)

Re:Python Language Summit: Python Without the GIL by Slaminerag on Thursday May 12, 2022 @01:42AM (#31349703)
20-odd years ago, my team solved some performance issues in our desktop app by splitting a couple of tasks into their own threads on a computer with a single CPU. Being able to write threaded code is really useful.
Re:Python Language Summit: Python Without the GIL by colinmhayes on Wednesday May 11, 2022 @11:01PM (#31348804)
Eh, even with true multithreading python will still be slow as molasses. If you want speed python will still not be your choice.
Re:Python Language Summit: Python Without the GIL by trashtester on Thursday May 12, 2022 @03:18AM (#31350297)
Some programming tasks are so trivial that processing speed is completely uninteresting.

Some are so compute heavy that massive amounts of time is put into tuning them (sort algorithms, fast-fourier transforms, etc).

Most fall somewhere on the spectrum between those extremes. If you can speed up your program by a factor of 20 by adding threads, Python can cover a bit more of that in-between spectrum.

Re:Python Language Summit: Python Without the GIL by saghm on Thursday May 12, 2022 @01:12AM (#31349527)
I'm not sure I fully buy this argument. I think programming languages are chosen for projects based on a number of different factors, speed being one of them, but developer productivity being another (and there are certainly many more). Given that there isn't usually going to be one language that is the best choice for every single factor, it seems pretty natural that some teams might pick Python due to productivity being more important but still have some need for better performance, and other teams might not be able to compromise on performance and have to resort to something like Java or Go or C++ but still would be able to iterate faster with something higher level. It's definitely not a given that there are enough potential projects that would get enough benefit from removing the GIL to make it worth it, but it seems silly to claim that anyone would would get any possible benefit from performance would never choose Python for other reasons.
Re:Python Language Summit: Python Without the GIL by pjmlp on Thursday May 12, 2022 @03:38AM (#31350453)
There are enough choices that offer Python's productivity alongside JIT/AOT options, better supported from the community than PyPy.

As for the C, C++, Fortran libraries with Python bindings, any language with FFI can call into them as well.

I would say, Python's adoption while lacking performance is what is now building pressure to avoid specific Python communities to leave Python and migrate into one of those ecosystems in search of a better mix of productivity/performance, without being forced to use two languages.

Re:Python Language Summit: Python Without the GIL by mavhc on Thursday May 12, 2022 @05:10AM (#31351186)
Which other languages do you suggest?
Re:Python Language Summit: Python Without the GIL by pjmlp on Thursday May 12, 2022 @06:13AM (#31351712)
Common Lisp, Scheme, Julia, Scala, Clojure, F#, OCaml
Re:Python Language Summit: Python Without the GIL by tentacleuno on Thursday May 12, 2022 @06:12PM (#31360726)
F# deserves its own category. You even get access to the .NET ecosystem for free. The developer experience is something else too.
Re:Python Language Summit: Python Without the GIL by pjmlp on Friday May 13, 2022 @03:24AM (#31364408)
Same applies to Common Lisp, Scheme, Scala and Clojure on the JVM/JavaScript platforms.

And Clojure also has a .NET implementation.

Re:Python Language Summit: Python Without the GIL by tentacleuno on Thursday May 19, 2022 @04:21AM (#31432056)
Ooh, a Clojure .NET implementation? This is news to me. From a quick look at the website, it looks really good... but how is it in practice? One of the major advantages of F Sharp's .NET integration is that it's developed by Microsoft, as of course they pretty much created the ecosystem from scratch.
Re:Python Language Summit: Python Without the GIL by fulafel on Friday May 20, 2022 @02:26AM (#31444004)
It doesn't get that many public use cases, here's the biggest one I've seen: http://arcadia-unity.github.io/

But it is being continuously kept up to date by Cognitect, along with active development on a clojure-clr-next version. Maybe it has a bigger population of non public users.

Re:Python Language Summit: Python Without the GIL by fulafel on Saturday May 21, 2022 @02:26AM (#31455726)
Also: here's another implementation of Clojure on CLR, "Morgan And Grand Iron Clojure Compiler": https://github.com/nasser/magic (see also http://nas.sr/magic/) of which there's a great cmpiler implementation talk (at Clojure/North) somewhere on Youtube.
Re:Python Language Summit: Python Without the GIL by orangetuba on Thursday May 12, 2022 @03:00AM (#31350145)
Performance is not binary. If you can be productive with Python and get closer to your performance goal, you get the best of both worlds. A lot of people who aren't primarily programmers don't have time to write everything in C++ (or keep up with development in that area). A more performant Python is a huge win for everybody.
Re:Python Language Summit: Python Without the GIL by pjmlp on Thursday May 12, 2022 @03:49AM (#31350544)
Just like language choice isn't binary, there are plenty of options with Python like productivity, with much better performance, it isn't Python vs C++.
Re:Python Language Summit: Python Without the GIL by metadat on Thursday May 12, 2022 @10:35AM (#31354836)
Not with a rich ecosystem like Python's.
Re:Python Language Summit: Python Without the GIL by pjmlp on Thursday May 12, 2022 @11:15AM (#31355388)
Quality matters more than quantity, and in that regard there are enough options available.
Re:Python Language Summit: Python Without the GIL by metadat on Thursday May 12, 2022 @11:33AM (#31355651)
This is a tire fire of a thread, it's clear there's lots of confusion about the tradeoffs.

This isn't a case of "x" or "y". There is literally nothing valuable about the GIL, it's an ugly hack of a vestigial appendage. Perhaps the reason I'm familiar with it is because the lack of elegant MP threading in Python perturbed me for years, until I was introduced to Golang.

Python devs generally don't want to use Java, JavaScript, etc. And the Go ecosystem is good but not as rich as Pythons.

Anyhow, take care pjmlp. Until our paths cross again I wish you all the best!

Re:Python Language Summit: Python Without the GIL by pjmlp on Thursday May 12, 2022 @12:35PM (#31356473)
As long as the use cases one cares about are covered, the amount of additional packages are needless noise.

JavaScript, Java, .NET, C and C++ are where to look for, if you want to count package numbers, for AOT/JIT languages.

Re:Python Language Summit: Python Without the GIL by rocqua on Friday May 13, 2022 @04:53AM (#31364946)
If python can get a trivial 4x speedup by replacing a for loop with a threadpool.map, then that is worth it to many python programmers.

Just because python isn't the fastest language in the world, does not mean that making it easier / possible to write faster python is worthless.

Re:Python Language Summit: Python Without the GIL by dekhn on Saturday May 14, 2022 @10:16AM (#31378122)
a few years back I was curious so I took a self-balancing robot that I had written in C (it did PID in real time to set motors in response to the current angle).

I ported it to Python, with a totally naive simple single threaded loop. It worked perfectly. 25 updates a second, forever. No C code, except the interpreter doing its thing, and some GPIO code.

That's not slow as molasses.

Re:Python Language Summit: Python Without the GIL by ctoth on Thursday May 12, 2022 @12:11AM (#31349194)
From upthread:

> My page load time dropped from 77ms to 47ms when I ran some of the code in parallel.

I suspect some of us welders will also find some improvements here.

Re:Python Language Summit: Python Without the GIL by coldtea on Thursday May 12, 2022 @04:49AM (#31350985)
That's just a 2x speed increase.

More than 5x can be achieved with the GIL included (and has been promised, by the new Microsoft Python-speed-up initiative and that Python dev who made a similar proposal).

Re:Python Language Summit: Python Without the GIL by ivoflipse on Thursday May 12, 2022 @05:18AM (#31351253)
That Python dev (Mark Shannon) is part of the Microsoft team :-)
Re:Python Language Summit: Python Without the GIL by throwaway894345 on Thursday May 12, 2022 @06:22AM (#31351795)
> I don’t think I’ve ever needed compute-concurrency, not in Python anyway.

I have. Some very inexperienced “senior engineers” at my last gig thought it would be fine to build an analytics platform in Python because “Pandas will make it fast”. Unfortunately even modest datasets would cause timeouts and even seize the event loop, while a naive Go prototype would finish in a few hundred milliseconds.

Re:Python Language Summit: Python Without the GIL by arc-in-space on Thursday May 12, 2022 @05:05AM (#31351143)
> Remember when it was discovered that arc welders could produce Carbon 60, and there was a huge run on arc welders?

No, I don't, and can't find any writing about this at all, do you have any links? Because that sounds amazing

Re:Python Language Summit: Python Without the GIL by Zanni on Thursday May 12, 2022 @05:47AM (#31351493)
Here's the text of a patent describing the process. [0] Googling "fullerene" will get you more useful hits than C-60, so, e.g. "generating fullerene from arc welding."

[0] https://patents.google.com/patent/US5227038A/en

Re:Python Language Summit: Python Without the GIL by CRConrad on Tuesday May 17, 2022 @06:46AM (#31408524)
Bing found two URLs... Both to this page. Google found one -- also here -- and two ads.

This:

   generate fullerene "arc weld"
Worked a bit better in both. N.B: Quote marks only around the "arc weld" bit.
Re:Python Language Summit: Python Without the GIL by gorgoiler on Thursday May 12, 2022 @07:30AM (#31352421)
I believe the original paper on Buckminsterfullerine aka Bucky balls aka C60 described the approach. Basically do violent stuff with carbon and stick it in a mass spectrometer. The violent carbon bit is arc welding, because the arc welding tips are made of graphite.
Re:Python Language Summit: Python Without the GIL by eesmith on Thursday May 12, 2022 @08:21AM (#31352938)
Wikipedia informs me that the first papers used a laser (https://www.nature.com/articles/318162a0 - "graphite has been vaporized by laser irradiation, producing a remarkably stable cluster consisting of 60 carbon atoms") (1985) and the arc welding approach was a few year later. The paper "Solid C60: a new form of carbon" (1990) paper describes using benzene to dissolve the soot to extract the C60 (https://heyokatc.com/pdfs/MISC/Solid_C60-_a_new_form_of_carb...).
Re:Python Language Summit: Python Without the GIL by jreese on Wednesday May 11, 2022 @11:58PM (#31349118)
Sam Gross works for Meta, and to my knowledge, this is his #1 project. So in effect, one of the largest companies depending on Python is funding this work.
Re:Python Language Summit: Python Without the GIL by dralley on Wednesday May 11, 2022 @11:51PM (#31349068)
I don't know if this is still true, but a few years ago there was only a single Python core developer that worked on it full time (Victor Stinner from Red Hat). The rest were only able to devote somewhere between few hours to one day a week.

https://discuss.python.org/t/official-list-of-core-developer...

Re:Python Language Summit: Python Without the GIL by waygood on Thursday May 12, 2022 @05:13AM (#31351206)
Microsoft has also been funding a team to work full-time on making Python faster: https://developers.slashdot.org/story/21/05/17/0225252/micro...
Re:Python Language Summit: Python Without the GIL by di on Thursday May 12, 2022 @12:35AM (#31349342)
Łukasz Langa now works full time on CPython via the PSF's Developer in Residence program.

https://pyfound.blogspot.com/2021/07/ukasz-langa-is-inaugura...

Re:Python Language Summit: Python Without the GIL by dralley on Thursday May 12, 2022 @10:28AM (#31354731)
Good to hear!
Re:Python Language Summit: Python Without the GIL by imron on Thursday May 12, 2022 @05:13AM (#31351212)
> If it's such a huge game changer why don't some of the large enterprises which rely on Python fund this work?

Because lots of code in python relies on the GIL to act as a synchronization primitive for threaded code (either explicitly or implicitly) and removing the GIL will break that code in subtle ways and there’s no appetite in those companies to fix that.

Re:Python Language Summit: Python Without the GIL by saghm on Thursday May 12, 2022 @01:03AM (#31349486)
It doesn't sound like the reservations of the people in charge of Python are about funding; I don't think it's as simple as "pay them $1m to merge the PR and then pay them salaries as they maintain it". Unless the assumption is that the people in charge of Python would take a bribe, I don't see how large companies could somehow magically make this happen with money short of just forking Python and trying to maintain it themselves, which would burn a ton of goodwill and likely not even win over the community.
Re:Python Language Summit: Python Without the GIL by latenightcoding on Wednesday May 11, 2022 @10:51PM (#31348744)
Because it's not a huge game changer. What would you do differently if the GIL was gone? when people need speed in Python they write C/C++ extensions or use multiple processes/computers
Re:Python Language Summit: Python Without the GIL by thelastbender12 on Thursday May 12, 2022 @12:33AM (#31349324)
>Because it's not a huge game changer.

That is just not true.

1 - This helps parallelize regular python code too, like the kind that goes into writing web services.

2 - While you'd still write native extensions to get optimum performance for single threaded code, having the thread dispatch layer in python makes parallelizing execution convenient and robust. For example, see the comment from people who maintain scikit-learn below. I'd love to see python get composable task parallelism like Julia where you can freely spawn threads within threads without worrying about their lifetimes.

link: https://github.com/colesbury/nogil/issues/36#issuecomment-10...

Re:Python Language Summit: Python Without the GIL by diffeomorphism on Thursday May 12, 2022 @01:22AM (#31349583)
That does not sound all that enthusiastic for a "game changer":

> helps parallelize

> convenient and robust

So nice but not too noticeable?

Re:Python Language Summit: Python Without the GIL by diordiderot on Thursday May 12, 2022 @01:47AM (#31349732)
Well context helps determine impact.

What percentage of compute time is python?

What percent of Py compute time would be cut?

Who's using python?(banks, stem researchers, everyone else)

Re:Python Language Summit: Python Without the GIL by diffeomorphism on Thursday May 12, 2022 @02:24AM (#31349941)
That has nothing to do with what I wrote and does not address the question?

> ...bunch of questions...

Yeah, if you claim that something is a "game changer" you should provide some arguments, not questions/"help determine".

It might very well be a game changer but thud far you have only suggested there might be an argument for that, if ...

Re:Python Language Summit: Python Without the GIL by pdhborges on Thursday May 12, 2022 @02:57AM (#31350127)
Well for web dev it would be simpler because you can get rid of workers which in turn reduces the overall memory footprint of applications since the code is shared, the local caches are shared and the connections are shared.

Edit: For backend services it would probably put Python around one order of magnitude away from Go in terms of memory usage to serve the same load, enough for teams not to consider switching.

Re:Python Language Summit: Python Without the GIL by oxfordmale on Thursday May 12, 2022 @04:46AM (#31350960)
Writing C/C++ extensions is super hard, and not something > 90% of the Python users is willing to pick up. I would love for Python to support a Parallel.ForEach statement as is supported in C#, or for Pandas to support parallel operations.
Re:Python Language Summit: Python Without the GIL by stinos on Thursday May 12, 2022 @03:00AM (#31350143)
Here's an example: embedding Python in other applications. Out of the box it's impossible to just start running scripts at will from multiple threads. Which happens to be what our application does, because as you say we want some speed/concurrency so have a backend running multiple threads C#/C++. But on top of that some things are customised in Python, and now we use IronPython which has no GIL so that all just works. Is this a huge game changer? As a whole, no, but for us: yes it would be awesome if we could just use Python.Net (which is just a layer over CPython) out of the box without having to deal with it's GIL.
Re:Python Language Summit: Python Without the GIL by rocqua on Friday May 13, 2022 @04:57AM (#31364966)
What if, when people in python need speed, they have the option to just replace a for-loop with threapool.map?

Currently, that doesn't do much. Trying to do this with a processPool either works, or becomes a horrible exercise in fighting with pickle or whatever other serializer you pick.

Re:Python Language Summit: Python Without the GIL by BlackFly on Monday May 16, 2022 @03:53AM (#31394520)
Run an ordinary database connection pool in shared memory mode instead of offloading it to a separate process via PGBouncer. Do that with all of the other resource pools as well. Heck, for one off webservers with low load you can do in memory session handling without needing to pull in memcache or redis until you truly need multiple processes or the sessions to survive a restart.

What would I do differently? Actually make engineering choices based on the current project status and priorities without having those choices made for me.

Re:Python Language Summit: Python Without the GIL by dataangel on Thursday May 12, 2022 @12:17AM (#31349219)
They've tried several times, see Unladen Swallow, but usually the projects are way more ambitious and also trying to introduce JIT.
Re:Python Language Summit: Python Without the GIL by ianai on Wednesday May 11, 2022 @10:45PM (#31348709)
Well, I might prefer a gofundme for some devs to do it. That way us average Joe’s can pitch into the support.

Otherwise, there’s making a fork and attempting periodic updates from python. That’d be a huge undertaking though.

FTA: “”” A lot of the value of Python is the ecosystem, not just the language… CPython really leads the way in terms of the community moving as a block.

"Removing the GIL is a really transformative step. Most Python programs just don’t use threads at the moment if they want to run on multiple cores. If nogil is to be a success, the community as a whole has to buy into it."

– Sam Gross”””

Re:Python Language Summit: Python Without the GIL by meta_throwaway on Wednesday May 11, 2022 @10:35PM (#31348625)
that's exactly what has happened.

edit: not sure why I got flagged, HN. Software engineer hours == funding.

Re:Python Language Summit: Python Without the GIL by 22SAS on Thursday May 12, 2022 @08:51AM (#31353326)
My thoughts exactly. Google has already done quite a lot of work on LLVM, as an example. Python is among their most used programming languages, this something they could totally assemble engineers to do.
Re:Python Language Summit: Python Without the GIL by Scarbutt on Wednesday May 11, 2022 @10:48PM (#31348727)
Because Java,C#,Golang,Javascript exist.
Re:Python Language Summit: Python Without the GIL by mateo411 on Thursday May 12, 2022 @12:31AM (#31349306)
Wait, does Javascript have good multi-threading support? I dont think it does.
Re:Python Language Summit: Python Without the GIL by mftb on Thursday May 12, 2022 @01:27AM (#31349607)
Worker threads[0]. If you don't follow Javascript it's not surprising you hadn't heard about it, it's pretty new. Node also, thanks to v8, pretty much outperforms Python.

[0]https://nodejs.org/api/worker_threads.html

Re:Python Language Summit: Python Without the GIL by frazbin on Thursday May 12, 2022 @01:47AM (#31349736)
worker threads don't share the parent's heap though, right? They can only share state through a binary channel. It's something, but pretty different from traditional pthreads.
Re:Python Language Summit: Python Without the GIL by mftb on Thursday May 12, 2022 @02:02AM (#31349821)
They can use SharedArrayBuffers[0] which wrap shared memory or they can pass ArrayBuffers. Node may not have the shared arrays yet, but the browsers do.

[0]https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re:Python Language Summit: Python Without the GIL by ptx on Thursday May 12, 2022 @06:05AM (#31351635)
Python has multiprocessing.shared_memory[1] since 3.8 to share arrays between processes, which accomplishes the same thing and circumvents the GIL issue.

[1] https://docs.python.org/3/library/multiprocessing.shared_mem...

Re:Python Language Summit: Python Without the GIL by jka on Thursday May 12, 2022 @07:43AM (#31352533)
> I wish Team Python would welcome GIL Eradication with open arms and a supportive attitude. This would look like focusing on helping identify and implement solutions to the impediments rather than simply pointing out problems and then helicoptering away.

It looks like they are supportive and keen on the changes? From the article:

> Gross's proposal was greeted with a mix of excitement and robust questioning from the assembled core developers.

It's definitely a huge opportunity, no doubt. But it affects the C ABI[1] for Python itself, something that everyone in the conversation is aware of, and that would have implications for all distributions of Python.

Add in the importance of effective code review for a 20k LoC changeset, and it seems there are good reasons to be cautious despite the optimism and excitement.

[1] - https://docs.python.org/3/c-api/stable.html#stable-applicati...

Re:Python Language Summit: Python Without the GIL by oxfordmale on Thursday May 12, 2022 @04:43AM (#31350937)
Yes, they need a lay out a plan on how to proceed. If they don't proceed with this, it will eventually result in the slow decline of Python and its eventual demise. Multi-threading in Python is an absolutely pain, and is something that needs to be addressed. We are at the end of Moore's law and CPU speeds have reached their limit. The only way forward performance wise is to kill the GIL.
Re:Python Language Summit: Python Without the GIL by throwaway894345 on Thursday May 12, 2022 @06:07AM (#31351654)
Kind of feels like Python is in a bit of a mess in no small part because the maintainers didn’t do a good job of blocking bad ideas. For example, exposing virtually the entire interpreter as the public C extension interface (can’t optimize much without breaking things, thus driving more dependence on C for performance which makes it even harder to change anything and leads to insanity in the Python packaging ecosystem).
Re:Python Language Summit: Python Without the GIL by baobob on Thursday May 12, 2022 @06:13AM (#31351715)
This is asking for Guido to have predicted the multicore era and the success of Python in 1991, at a time when SMP architectures had only been commercially available on extremely expensive systems for 5 years. Much of what contributed to that success was in fact the rich C API, and the ease with which it could be embedded into larger applications, and I'm not sure what an alternative would look like that could produce efficient implementations of things like Numpy, etc.
Re:Python Language Summit: Python Without the GIL by rkangel on Thursday May 12, 2022 @07:34AM (#31352454)
This is what I find most interesting about the Erlang/Elixir world. The programming language design predated SMP by about 20 years - the actor model was chosen because it was a good way to reason about programs not for parallelism. Then multicore processors arrived, and it was 'just' a VM enhancement to make Erlang programs fully parallelised.

Sometimes you just get lucky.

Re:Python Language Summit: Python Without the GIL by throwawaymaths on Thursday May 12, 2022 @09:59AM (#31354296)
Just a nitpick -- the actor model was not chosen, the BEAM just happens to look like an actor model. The BEAM architecture was chosen for fault tolerance and the features you want for fault tolerance naturally guide you to something actor-ish. Also, the actor model says very little about fault tolerance concern (its concern is in improving computational efficiency bottlenecks)
Re:Python Language Summit: Python Without the GIL by throwaway894345 on Thursday May 12, 2022 @10:09AM (#31354450)
> This is asking for Guido to have predicted the multicore era and the success of Python in 1991

No, it’s not. My comment applies to single threaded performance as well (I wasn’t even thinking about the GIL when I made my comment)—why isn’t Python as fast as modern JS implementations, for example? The answer isn’t “JS has multi thread support”.

Moreover, a slim C extension interface is about flexibility so you don’t paint yourself into a corner when you don’t know what the world might look like tomorrow. Further, you can have a very rich C extension API without exposing the entire interpreter (e.g., h.py). Further still, Python has broken compatibility several times since its inception, so the idea that this was cemented in 91 is nonsense.

Re:Python Language Summit: Python Without the GIL by baobob on Thursday May 12, 2022 @10:53AM (#31355092)
> why isn’t Python as fast as modern JS implementations, for example?

Because the project has explicitly targeted implementation simplicity, largely successfully, for almost 30 years. The internals are a joy to work on, and unsurprisingly the CPython Git repository has 4x as many contributors as v8, despite CPython contribution being largely voluntary and v8 contribution being largely commercial.

Even if performance were an explicit goal, it's important to remember v8 required absolutely massive funding and top tier engineering support to make it happen at all. The most comparable equivalent in the Python world, PyPy, was the product of an extremely dedicated group of mostly doctoral researchers working against incredible odds. V8 only has 2x as many contributors as PyPy. I hope by now you are recognizing a theme: the reason the language is so successful is also the reason we are here complaining about it.

There have been teams in at least Google and Dropbox who proposed major upheavals of the interpreter in the past. Both failed in large part due to the complexity of their proposals compared to the performance gains on offer

Re:Python Language Summit: Python Without the GIL by throwaway894345 on Thursday May 12, 2022 @01:23PM (#31357123)
You're setting up a dichotomy between a small C-extension interface and code simplicity, but this doesn't make sense. A smaller interface is inherently simpler--it's less for developers to work around, and they can deliver more user value (whether performance or otherwise) per unit complexity.

> The most comparable equivalent in the Python world, PyPy, was the product of an extremely dedicated group of mostly doctoral researchers working against incredible odds

"incredible odds" refers to compatibility with the CPython C-extension interface, which is exactly what I'm talking about.

> There have been teams in at least Google and Dropbox who proposed major upheavals of the interpreter in the past. Both failed in large part due to the complexity of their proposals compared to the performance gains on offer

No, they failed because they had to work within the considerable constraints imposed by historically bad decisions (such as the C-extension interface). The proposals need to be complex because they can't break compatibility.

> I hope by now you are recognizing a theme: the reason the language is so successful is also the reason we are here complaining about it.

Not at all! A narrower C-extension interface doesn't imply that C-extensions would be more difficult to write. There are no downsides to a narrower interface (apart from breaking compatibility, but we're positing a world in which this decision was made in 2008 or earlier).

The real theme here is that historical bad decisions + compatibility guarantees add significant complexity to every single improvement if they don't preclude them altogether.

Re:Python Language Summit: Python Without the GIL by mikepurvis on Thursday May 12, 2022 @06:44AM (#31352008)
I think a more reasonable timeframe for this discussion is the release of Python 3 in 2008. That was much more recently, clearly in the multicore era, and a major opportunity to do a breaking change.
Re:Python Language Summit: Python Without the GIL by eesmith on Thursday May 12, 2022 @07:30AM (#31352420)
There were multiple discussions. The main issue was removing the GIL made single-threaded Python. Experiments in 1999 found single threaded performance was 50% slower - you would need 2 cores just to break even, assuming you had parallel code in the first place.

Here's a 2007 essay by van Rossum on the topic: https://www.artima.com/weblogs/viewpost.jsp?thread=214235 .

> I'd welcome it if someone did another experiment along the lines of Greg's patch (which I haven't found online), and I'd welcome a set of patches into Py3k only if the performance for a single-threaded program (and for a multi-threaded but I/O-bound program) does not decrease.

Re:Python Language Summit: Python Without the GIL by peatmoss on Thursday May 12, 2022 @05:31PM (#31360359)
Arguably, Guido was in a great position to be thinking about concurrency in 1991: https://en.wikipedia.org/wiki/Amoeba_(operating_system)
Re:Python Language Summit: Python Without the GIL by riyadparvez on Wednesday May 11, 2022 @10:34PM (#31348617)
I am curious what exactly is the reason GIL hasn't been removed in one of the most popular languages ever?
Re:Python Language Summit: Python Without the GIL by haney on Wednesday May 11, 2022 @10:44PM (#31348706)
Until now attempts to remove the GIL have come at the cost of reduced single threaded performance.

This is the first suggestion that doesn’t degrade single threaded performance.

Re:Python Language Summit: Python Without the GIL by kzrdude on Thursday May 12, 2022 @01:52AM (#31349763)
Well, all credit to Sam the author, but he "bought" that no degraded performance by adding performance optimizations! Unfortunately, Python 3.11+faster-cpython work has already superseded some of it, i.e negating the trade-in he's trying to accomplish! However, I still hope everyone helps out and that the nogil work can land as default in CPython.
Re:Python Language Summit: Python Without the GIL by josefx on Thursday May 12, 2022 @06:01AM (#31351598)
> Unfortunately, Python 3.11+faster-cpython work has already superseded some of it,

Why is that unfortunate? If his patch being slower than python 3.11 isn't acceptably fast despite being faster than every other python version before that then python was never acceptably fast to begin with.

Linux got rid of the BKL ages ago, that the Python community still holds onto the GIL as if it was some multi threading holy grail isn't even remotely funny anymore.

Re:Python Language Summit: Python Without the GIL by kzrdude on Thursday May 12, 2022 @12:48PM (#31356612)
It's unfortunate because I think it makes it slightly less likely that his work is accepted, now that part of the sweet single thread performance gains are already supplied from another source.
Re:Python Language Summit: Python Without the GIL by coldtea on Thursday May 12, 2022 @04:54AM (#31351028)
>Unfortunately, Python 3.11+faster-cpython work has already superseded some of it, i.e negating the trade-in he's trying to accomplish!

If "Python 3.11+faster-cpython" didn't also remove the GIL, then it didn't negate anything he's trying to acomplish. He wasn't going for a faster Cpython alone, but for a Cpython without GIL.

Re:Python Language Summit: Python Without the GIL by dagw on Thursday May 12, 2022 @01:31AM (#31349636)
The first Gil-removal patch I'm aware of was against python 1.4, so it's not like people haven't been trying. The problem has never been removing the GIL per se, but removing the GIL without slowing down the language when running single thread
Re:Python Language Summit: Python Without the GIL by fulafel on Thursday May 12, 2022 @10:37AM (#31354848)
You could compile Python using the --without-threads configure option, before Python 3.7 [1] or thereabouts.

[1] 3.7.0 is the first major release following the removal of the config option in https://github.com/python/cpython/issues/75551 .. there's also a 2021 comment about "This has unfortunately turned out to be a blocker on getting WASI support as there's not direct threading support in WebAssembly."

Re:Python Language Summit: Python Without the GIL by digisign on Thursday May 12, 2022 @12:35AM (#31349337)
Popular but historically un/underfunded.
Re:Python Language Summit: Python Without the GIL by coldtea on Thursday May 12, 2022 @04:56AM (#31351057)
Also: there were lots of independent projects to remove the GIL/speed up Python: from Google, Dropbox, and others.

But due to the leadership/community model/aversion to big changes (except for alienating people with 2 to 3 changes) none of this was in the context of CPython, they were independent versions, that never caught on, and didn't leave anything (or much) behind to the regular CPython when they folded.

Re:Python Language Summit: Python Without the GIL by mumblemumble on Thursday May 12, 2022 @09:21AM (#31353740)
> It cannot be understated, removing the GIL will be a HUGE deal for Python! It's an ugly wart which has existed for about 30 years

I would argue the opposite: it's the secret to Python's success. It might even be my top example of how "worse is better" plays out in real life.

I agree, the GIL feels like an ugly hack. The software engineer in me wants to hate it so much. And, now that I'm on the far side of a successful transition to a data science role, one might think that I hate it even more, yeah? Because the work I'm doing depends so very heavily on compute performance and parallelism.

But it turns out, nah, I'm coming to like it. It's an ugly hack, but it's the best kind of ugly hack: one that gets the job done.

Because I'm pretty sure that the GIL is the secret sauce that makes Python C extensions work so well. Without it, it would be much more difficult to write safe, correct C extensions. Doing it without introducing race conditions that destroy memory safety would be a black art. So people would probably do it less. And that probably means no robust Python scientific computing or data science ecosystem, because that stuff is all C extensions.

We could instead use a C FFI, like it's done in other languages. Java, for example. But Java having to use an FFI and Python being able to use its C extension mechanism is exactly why Python has eaten all of Java's Wheaties in the data space. The marshaling costs of talking back and forth across that boundary are just too high. Copying goes up, locality of reference goes down, cache misses go up. You saturate the memory bus more quickly. Once you've done that, it doesn't matter how many threads you have running on how many cores. The bottleneck is happening outside the CPU. Top will happily tell you those cores are working hard, but it turns out that what they're working so hard at is sitting around and waiting.

This isn't just theoretical. Last year I replaced a heavily parallelized compute-heavy batch process written in Java with a Python implementation that got the work done in less time despite being single-threaded. Sure, the Python implementation was basically a little scripting on top of a library written in C++, and the Java one was pure Java. But that's kind of the whole point. I also know that, back when I wrote the original Java implementation, I tried the same trick of farming the calculation out to a C++ library, and it actually made the throughput even worse. JNI is a harsh master.

And besides, as others have said, numpy & friends give me most the parallelism I actually need, for free.

Maybe it hurts other people more? Maybe Web developers? But there's a part of me that thinks, if you're trying to do that kind of work at scale, making Python go faster is perhaps barking up the wrong tree. There are plenty of other languages that are statically typed (reducing pointer chasing and branching can increase your throughput without giving Amazon more money in the process) and don't even need a global interpreter lock in the first place because they're not interpreted, either.

Re:Python Language Summit: Python Without the GIL by mcherm on Thursday May 12, 2022 @12:11PM (#31356170)
I am not persuaded. I think that C extensions could handle multi-threading more easily or could simply document that they only support single-threaded use. BUT, I had never heard this argument made and I find it a very interesting and insightful one -- thank you for explaining in detail!
Re:Python Language Summit: Python Without the GIL by RcouF1uZ4gsC on Thursday May 12, 2022 @06:51AM (#31352090)
> It cannot be understated, removing the GIL will be a HUGE deal for Python!

I am not sure about it. Python explicitly trades performance for simplicity and the GIL simplifies a whole lot of things and because of it, there are multi threading issues that will never be encountered by Python code.

In addition, because of Python’s popularity, there is a massive amount of code written in Python (and other languages as extensions) and any change cannot introduce a bug.

Finally, there are other alternatives to Python that are more performance focused.

If you are having huge issues with Python performance, maybe you are using it in a matter it was not designed for.

Re:Python Language Summit: Python Without the GIL by sshlocalhost98 on Thursday May 12, 2022 @03:11AM (#31350227)
Can anyone elin (explain like I am noob), why should the Gil be removed? Why need concurrency in normal python scripts let’s days for web scraping or machine learning ? I don’t really get it.
Re:Python Language Summit: Python Without the GIL by coldtea on Thursday May 12, 2022 @04:52AM (#31351012)
>Can anyone elin (...) Why need concurrency in normal python scripts let’s days for web scraping or machine learning ? I don’t really get it.

That's not a noob question. That's a loaded question, from a perspective of knowing what people use Python for.

People use Python for all kinds of things, and a lot of them would be faster if they were able to take advantage of multithreading without the GIL.

Re:Python Language Summit: Python Without the GIL by ModernMech on Thursday May 12, 2022 @08:32AM (#31353071)
True but they would also be faster (probably more so) if Python had a jit compiler. Just seems that people want Python to be something other than it is. I guess the assumption is that it’s easier to remove the GIL or jit Python than the alternative, which would be to port whatever libraries to another ecosystem. Maybe a safe bet although there’s no deadline for GIL removal and that’s been a goal for decades.
Re:Python Language Summit: Python Without the GIL by coldtea on Thursday May 12, 2022 @08:52AM (#31353339)
>Just seems that people want Python to be something other than it is.

Well, if they didn't, we'd still be stuck with Python 1 or 0.1.

Why is the GIL suddenly where Python should keep "being what it is", and not any of those tons of changes, from 0.1 to 3.10?

Especially since the removal of the GIL doesn't change any spirit/essence of Python - just makes it faster.

Python wasn't conceived as "having a GIL" being some essential part of it, it was just a bad tradeoff for implementation convenience made back in the day where common multi-core machines were 20 years in the future...

Re:Python Language Summit: Python Without the GIL by sshlocalhost98 on Saturday May 14, 2022 @12:14AM (#31375028)
Thank you sir/ma’am for the explanation!
Re:Python Language Summit: Python Without the GIL by josefx on Thursday May 12, 2022 @04:40AM (#31350911)
Going by the paper it also improves performance even for single threaded code[1]. The GIL is just dated design, there isn't anything good about it.

[1]https://docs.google.com/document/d/18CXhDb1ygxg-YXNBJNzfzZsD...

> Why need concurrency in normal python scripts let’s days for web scraping or machine learning ?

I had a few scripts where I had to process over a hundred files, just running that in parallel can reduce a job that takes minutes to seconds.

Re:Python Language Summit: Python Without the GIL by ptx on Thursday May 12, 2022 @06:19AM (#31351763)
As some other commenters have mentioned, the GIL removal branch also makes some unrelated optimizations and the performance improvement comes from those rather than from the GIL removal itself, as I understand it.

From your link:

"Stripping out some of the GIL-removal related changes would result in even faster performance on the single-threaded pyperformance benchmark suite. [...] The resulting interpreter is about 9% faster than the no-GIL proof-of-concept (or ~19% faster than CPython 3.9.0a3). That 9% difference between the “nogil” interpreter and the stripped-down “nogil” interpreter can be thought of as the “cost” of the major GIL-removal changes."

So it seems removing the GIL has a negative impact on single-threaded code, with the version that has both the GIL and the unrelated optimizations being 9% faster.

Re:Python Language Summit: Python Without the GIL by sshlocalhost98 on Saturday May 14, 2022 @12:27AM (#31375084)
Thank you sir/ma’am for the explanation! The Google docs was an excellent resource.
Re:Python Language Summit: Python Without the GIL by formerly_proven on Thursday May 12, 2022 @04:58AM (#31351077)
Python is not actually a single-purpose language for calling numpy or tf.
Re:Python Language Summit: Python Without the GIL by WorldMaker on Thursday May 12, 2022 @05:18PM (#31360223)
In that case, maybe Python should just directly transpile to FORTRAN and save some C bridges? Python's syntax does resemble FORTRAN some days.
Re:Python Language Summit: Python Without the GIL by disgruntledphd2 on Thursday May 12, 2022 @07:42AM (#31352524)
Yeah, I hear it can call pandas too \s
Re:Python Language Summit: Python Without the GIL by stjohnswarts on Thursday May 12, 2022 @10:20AM (#31354635)
I agree and have been complaining about it for ages. Mostly got around it via using processes and microservices, but this would make my life so much easier. With general processors having tons of cores and memory now it just doesn't make sense, especially if the new changes work well with little or no performance hit. Seems like a no brainer.
Re:Python Language Summit: Python Without the GIL by ghqmlp on Thursday May 12, 2022 @05:44AM (#31351474)
It is all political at this point. Python is run by representatives of big corporations, some of whom haven't really done anything in the past 10 years but are who great at promoting their personal brands.

They are trying to strengthen corporate influence and discourage any power of traditional independent open source developers (who have contributed most of the useful features as opposed to corporate churn).

We do not know what is going on in the background, it is proxy wars all over the place. It is possible that they want to reduce Facebook influence, that their code bases do not need this feature, etc.

Just use C++.