by paulddraper · 3y ago · 0 comments
No one's flipping a switch and breaking mountains of sketchy C.
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.
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.
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.
I suppose the need to run your app in "no-GIL" mode is less than needing to jump from 2.7 to 3.
It also seems like the latter isn't meant as a replacement (for the moment), but rather as an option.
stat = rt_oldFunctionName(&newStateArg, oldarg[,...])
mostly (again from memory. I'd not live or die by this)> We want to be very careful with backward compatibility. We do not want another Python 3 situation …
Entirely different from 2->3.
That analogy is so poorly applicable it's laughable.
"Dur dur this <insert anything here> is just like 2 -> 3."
HN had always been susceptible to drive-by ignorant comments, but it's reaching new levels.
There's literally nothing of substance to the suggestion. (And if you think there is, present an actual informed argument.)
Long term the plan is to 100% remove the GIL from python.
From the article:
> Long-term, we want no-GIL to be the default, and to remove any vestiges of the GIL (without unnecessarily breaking backward compatibility). We don’t want to wait too long with this, because having two common build modes may be a heavy burden on the community (as, for example, it can double test resources and debugging scenarios), but we can’t rush it either. We think it may take as much as five years to get to this stage.
Under base assumptions it also says:
> We want to be very careful with backward compatibility. We do not want another Python 3 situation, so any changes in third-party code needed to accommodate no-GIL builds should just work in with-GIL builds (although backward compatibility with older Python versions will still need to be addressed).
* update: I have also lived through 10 years of Python 2-3. It was not pretty.
Surely, unattended-upgrades should NOT be bumping major versions?
Ugh, Nomenclature is hard
Because non-GIL compatible doesn't mean GIL incompatible