by qbasic_forever · 3y ago · 0 comments
No, none of them do, or at least none that I’ve ever seen in 4 years of doing rust full-time.
Or you make the extra effort of being thread safe and you can declare your library as not requiring the GIL.
Now if a user script mixes your GIL free lib with an older lib that has not been updated, well, too bad for them. Even with your hard work, the code will still operate like before, everything gets the GIL treatment.
Normal python devs will need to track down which pesky dependency of their script is causing the GIL slowdown. Kinda sucks but at least nothing breaks.
It's a sensitive, opt-in, and safe way forward. Hard to argue against it, really..
> In --disable-gil builds, when loading an extension, CPython will check for a new PEP 489-style Py_mod_gil slot. If the slot is set to Py_mod_gil_not_used, then extension loading proceeds as normal. If the slot is not set, the interpreter pauses all threads and enables the GIL before continuing. Additionally, the interpreter will issue a visible warning naming the extension, that the GIL was enabled (and why) and the steps the user can take to override it.
Why then is there even a need for a seperate nogil build? If it is like this says, wouldn't it be easier to just make the standard build switch to gil or nogil automatically (or honor the users choice).
The fact that the SC thinks having two versions suggests there is more complexity involved than this section of the PEP leads readers to believe.
How does one library support both GIL and no-GIL?
Easy, it supports no-GIL, so it supports both. Done.
The problem -- as you point out -- with 2 -> 3 was that supporting both versions was very difficult. Because Python 2 couldn't run Python 3 code (and vice versa).
And thus libraries existed in awkward states for years.
But GIL can run no-GIL code. Supporting both is no harder than supporting one of those options (the no-GIL one).
This “that’s not how it went” stuff going down is quite just blatant historical revisionism.
Maybe it’s a good idea? Maybe it’s not?
…but anyone down voting “this reminds me of the Python 2/3” fiasco has no idea what they’re talking about.
Historically, Napoleon lost. That has zero impact on whether I get a promotion.
The 2 changes simply have nothing to do with each other. No-GIL python can still run GIL code, it just won't be able to run it in parallel.
If the burden becomes too big, at some point people may find it is the easier option to switch to a different ecosystem. I hope not.
That's by far the most unpleasant language I've coded in.