r/Python • u/anyfactor Freelancer. AnyFactor.xyz • Sep 16 '20
News An update on Python 4
18
333
Sep 16 '20
What was the transition from 1 to 2 like?
270
u/NoLongerUsableName import pythonSkills Sep 16 '20
If this article is accurate, it was pretty smooth, unlike the transition from 2 to 3.
→ More replies (5)60
u/roerd Sep 16 '20
Here's the list of the most important changes:
Overview of Changes Since 1.6
There are many new modules (including brand new XML support through the xml package, and i18n support through the gettext module); a list of all new modules is included below. Lots of bugs have been fixed.
The process for making major new changes to the language has changed since Python 1.6. Enhancements must now be documented by a Python Enhancement Proposal (PEP) before they can be accepted.
There are several important syntax enhancements, described in more detail below:
Augmented assignment, e.g. x += 1
List comprehensions, e.g. [x**2 for x in range(10)]
Extended import statement, e.g. import Module as Name
Extended print statement, e.g. print >> file, "Hello"
Other important changes:
Optional collection of cyclical garbage
So quite a few important new features, but nothing that was breaking backwards compatibility.
61
u/mkdz Sep 16 '20
Wow, I can't imagine not having list comprehensions
46
Sep 17 '20
List comprehension is the feature that, to me, defines Python. It's simple, powerful, versatile, intuitive, and broadly applicable. A wonderful replacement for loops and iteration. I've been using set comprehension and dictionary comprehension, too.
→ More replies (5)20
u/Mr-Stutch Sep 17 '20
a wonderful replacement for loops or a wonderful replacement for loops?
→ More replies (3)11
28
7
u/case_O_The_Mondays Sep 17 '20
Whoa. Didn’t know Python supported redirection on print, back in the day.
0
Sep 17 '20
[deleted]
2
u/case_O_The_Mondays Sep 17 '20
Right, but from the example it used to be more like shell redirection.
9
Sep 17 '20
That's what the syntax was inspired by but it was universally disliked. Looked really jarring from the rest of Python. It died with the print statement.
3
1
u/alexmojaki Sep 17 '20
Breaking backwards compatibility is kind of the point of a major version number bump though.
1
u/roerd Sep 17 '20
If you're following semantic versioning, yes. But not every software project has to do that. For a programming language, a bunch of new features that will significantly alter the shape of code using these seems justification enough for a new major version to me, even if full backwards compatibility is maintained.
386
Sep 16 '20
Nothing compared to the transition from 0 to 1.
145
u/NoLongerUsableName import pythonSkills Sep 16 '20
Yeah, it was kind of like the transition from -1 to 0.
128
Sep 16 '20
-1 was dark times
99
u/ShevekUrrasti Sep 16 '20
Coding backwards was kind of nice, actually.
100
u/mdarty Arch Sep 16 '20
I'm great at that. Taking working code, breaking it. Troubleshooting and finally deleting everything.
12
→ More replies (1)7
→ More replies (4)41
22
u/TheHumanParacite Sep 16 '20
Installing it would randomly unwrite code that hadn't yet been written.
11
u/master5o1 Sep 16 '20
The real trick was to uninstall it and get unwritten code to be randomly written.
→ More replies (1)5
20
→ More replies (1)3
2
→ More replies (2)1
29
u/twotime Sep 16 '20
It was mostly (if not fully) backward compatible. So much easier and faster than 2=>3
17
u/jrbattin Sep 16 '20
Buttery smooth. I “ported” 8000 lines of Python code from 1.5.2 to 2.6 years ago. It took a day or so and that’s only because I insisted on refactoring in Python 2.6 niceties and leaning on the standard library more.
22
u/MrCaptainPirate Sep 17 '20
Transitioning from 1 to 2 was like going down a nice water slide
Transitioning from 2 to 3 was like going down a piping hot stainless steal slide in the middle of summer and then getting hit in the face with a brick at the end.
4
2
u/Ran4 Sep 17 '20
It's not that bad... Not even remotely.
3
u/pithed Sep 17 '20
It really depends on your codebase. For some of my projects I just needed to change a couple of lines of code and can't believe I waited for so long. For other projects, which depend on libraries that weren't updated, it has been a whack-a-mole of terrible. I had an easier time going from PERL to Python.
1
u/thephoton Sep 17 '20
Bitch all you want about the Python 2 -> Python 3 transition, it was a hell of a lot smoother than Perl 5 -> Perl 6.
1
u/MrCaptainPirate Sep 17 '20
I’m not super familiar with PERL or it’s transition from 5 to 6, but from what I’ve heard it’s about as fun as trying to pass a kidney stone.
2
u/thephoton Sep 17 '20
To summarize: Perl 6 work started in 2000 and AFAIK there is still no complete implementation and effectively no user adoption.
The fact that Python has effectively taken over nearly all of Perl's market share in the meantime probably has something to do with that (but it's not the only reason).
→ More replies (1)
51
u/Hall_of_Famer Sep 16 '20 edited Sep 16 '20
Guido said that a while ago that the version after 3.9 would be 4.0, but then it seems that they decided to make it 3.10 to be consistent with semver. Python 4.0 will most likely be very different from Python 3.x, with a lot of new features and changes in the internal VM. In this case though, its interesting to see how they plan to make the transition smooth instead of another Python 2 vs 3 chaos.
Whatever will happen, lets hope that at the very least, Python will stick with the the Zen(PEP 20) that 'Simple is better than Complex' and 'There should be one, and preferably only one obvious way to do it'. These are the characteristics of Python that makes it easier for beginners/data scientists, and part of the reason why it beats Perl and Ruby in terms of popularity.
22
u/lordmauve Sep 16 '20
They didn't make it 3.10 to be consistent with SemVer; if they used SemVer every release would be a major release and we would be on Python 22 by now.
They changed it to 3.10 because
Guido isn't in charge any more, so the steering council doesn't have to stick to his preferences
2 -> 3 was such a mess that nobody wants to raise the spectre of that again
They did some analysis of whether more stuff would break with sys.version_info returning (4, 0) or (3, 10) and found that way more stuff breaks if it is (4, 0)
37
u/ExceedinglyEdible Sep 17 '20
way more stuff breaks if it is (4, 0)
if platform_name.startswith('Windows 9'): …13
u/masteryod Sep 17 '20
2 -> 3 was such a mess that nobody wants to raise the spectre of that again
They broke backwards compatibility for a reason. They announced it, planned for migration, gave people tools to port and documentation. They gave people heads-up and then after backlash extended Python 2 death sentence by whooping 5 years which ended with 2020. And yet people are still salty because their script doesn't work with new version. There's even a guy who wanted to maintain his own port of Python 2 to keep his application on it (Calibre)...
It's like writing something in GTK2 and expect the code to work the same on GTK3.
3
u/lordmauve Sep 17 '20
They broke backwards compatibility for a reason. They announced it, planned for migration, gave people tools to port and documentation. They gave people heads-up and then after backlash extended Python 2 death sentence by whooping 5 years which ended with 2020
Sure, and now the CPython core devs generally acknowledge that it was a mistake to do it like they did it. Not the result, or the reasons: the approach.
So, never again.
1
u/neuronet Sep 17 '20
No matter how many words people use, the objective upshot by any reasonable person must be...the 2 to 3 transition sucked.
1
u/kankyo Sep 17 '20
Seems a bit short sighted though. So we're at 3.8 now, with one release per year. That's gonna look very stupid very fast. The "3." could be dropped. I don't like to say good things about Java, but they actually did the right thing here.
4
1
u/8day Sep 17 '20
3.8 broke a lot of stuff, so for me 4.0 was already released. Just look at the chaos 3.8 caused for CPython extensions: PySide2 (GUI) was broken for quite some time (threading issues), VapourSynth (NLE for multimedia), probably some other distros.
95
u/vallas25 Sep 16 '20
Can someone explain point 2 for me? I'm quite new to python programming
282
Sep 16 '20
Think what he is saying, there will never be a Python 4 and if there is, it will be nothing like python as we know it. It will be like a new language
The transition from python 2 to 3 was an absolute nightmare and they had to support python2 for *ten years* because so many companies refused to transition. The point they're making is that they won't break the whole freaking language if they create a python 4.
77
u/panzerex Sep 16 '20
Why was so much breaking necessary to get Python 3?
180
u/orentago Sep 16 '20
Having strings support unicode by default was a big reason. In Python 2 unicode strings had to be prefixed with a
u, otherwise they'd be interpreted as ASCII.47
Sep 16 '20
That was just ascii for trouble imho.
15
6
u/17291 Sep 16 '20
You're not going to like Python 5, where string literals default to EBCDIC.
→ More replies (2)0
Sep 16 '20
[deleted]
82
Sep 16 '20
I have prod 2.7....talking to logic written in the 90s.
Kill me.
56
Sep 16 '20 edited Sep 17 '20
Python3 > Datastage > Python2 > Shell (Kornshell) > Perl written in '99 across servers.
I'll have one kill please.
→ More replies (5)8
u/MiscWalrus Sep 17 '20
It's not like the rules of logic changed since the 90s. You could do a lot worse than having to support python 2.7.
→ More replies (3)11
u/lzantal Sep 17 '20
Still maintaining one in production with Python 2.4 and Django 1.3 🙄😬
→ More replies (6)4
73
u/flying-sheep Sep 16 '20
Because they changed a core datastructure.
strused to be whatbytesis today, but it also predatedunicode(today calledstr). Therefore thebytestype was used for text and binary APIs.When fixing all this, they had to break a lot of core APIs that used to accept
bytesand today sensibly only accepts the unicodestr.And because of that huge change they also took the opportunity to change a few other idiosyncrasies.
My only gripe: One additional thing they should have changed is that
{}should be the empty set and{:}should be the empty dict.21
u/miggaz_elquez Sep 16 '20
you can write
{*()}to have an empty set if you want32
26
u/Brainix Sep 17 '20
My favorite thing about
{*()}is that you don't even save any characters over typingset(). 😂→ More replies (1)→ More replies (1)6
33
u/irrelevantPseudonym Sep 16 '20
My only gripe: One additional thing they should have changed is that
{}should be the empty set and{:}should be the empty dict.Not sure I agree with that. It's awkward that you can't have a literal empty set, but having
{:}would be inconsistent and a special case that (I think) would be worse thanset().→ More replies (20)8
u/james_pic Sep 16 '20
Perhaps surprisingly (given what we know now about the migration process), the switch to unicode strings wasn't expected to be a big deal (it didn't even get its own PEP, and was included in a PEP of small changes for Python 3 - PEP 3100), and the other changes were seen as more break-y.
→ More replies (3)5
u/zurtex Sep 16 '20
Set literals (e.g.
{1, 2, 3}) were added in Python 2.7 and Python 3.1.So to change the very common empty dict notation of
{}would of required breaking backwards compatibility between 3.1 and 3.0 and either not being able to accurately back-port the feature to 2.7 or breaking compatibility between 2.7 and all other 2.x versions.It was decided, fairly rightly, that it would of been too much churn for the fairly minimal aesthetic niceness / consistency benefits.
{}is littered in code all the time whereasset()is pretty rare.→ More replies (1)2
Sep 16 '20
Oooooh so that's why I'm confused each time I read what bytes does?
4
u/flying-sheep Sep 16 '20
Maybe, but maybe it's because you didn't have an introduction to binary yet.
→ More replies (2)4
Sep 17 '20
The explanation is confusing. Just ignore how it was before, because it was incorrect. In python 2 first mistake was mixing text with binary data. They introduced unicode type, but did so badly (implicit casting) it actually made things worse. Ironically if your application didn't use unicode type you might have less work converting it to work with python 3.
Right now it is:
str = text
bytes = binary data what's stored on disk, flies over network etc.
23
Sep 16 '20
Python 3 was not backwards compatible with 2, so companies and package creators alike were initially hesitant to make the switch so as to not break things. There also weren’t many, if any, tools to help port things over.
The lack of backwards compatibility was done on purpose because part of their goal was to remove clutter and make things more intuitive/easier to use (e.g.
12
u/DiggV4Sucks Sep 16 '20
I've only made two unassailable (so far) decisions in my career. The first was to support MFC instead of OWL for Windows development.
The second was to target Python 3 for my current company's testing efforts. We were even able to convince a medium sized tool vendor to support both Python 2 and Python 3 from their original decision to support only Python 2.
2
u/Nolzi Sep 16 '20
There also weren’t many, if any, tools to help port things over.
I have no real world experience with python, but weren't there tools like 2to3 to convert code, or the future package to write code compatible with both versions?
→ More replies (2)5
Sep 16 '20
The lack of backwards compatibility was done on purpose
This was the problem. Until we're on the other side of the next upgrade and it wasn't like 2.x to 3.x was, words mean nothing.
13
u/gregy521 Sep 16 '20
It was designed to rectify fundamental design flaws in the language—the changes required could not be implemented while retaining full backwards compatibility with the 2.x series, which necessitated a new major version number. The guiding principle of Python 3 was: "reduce feature duplication by removing old ways of doing things".
Here's a short list of some of the key changes. The most obvious of which is the change where '/' represents true division instead of floor division. Some other changes exist, print is now a function, not a statement. You also get iterator objects instead of lists, which is much better for memory management (many pieces of code rely on iterators because the full set of possible options doesn't fit in memory). True, False, and None are also now protected terms which can't be reassigned.
15
u/daturkel Sep 16 '20
Part of any long-term tech project is continuous refactoring. Early on you make certain design decisions which later become an obstacle when trying to expand a feature, so you rewrite early stuff in order to make it more flexible for your new needs.
Often those rewrites are done in ways such that the end user does not need to adapt their behavior (or in the case of a programming language, does not need to change their code). This is the ideal experience for the end user but can also constrain the types of changes that can be made.
Sometimes you realize that the original way of doing things was worse and that it would be creating more difficulty for future development to maintain compatibility, so breaking changes are introduced.
4
Sep 16 '20
the biggest issue was that python before 3 was mixing string with bytes. This is fine if you use encoding that covers 256 characters, but most of Python 2 code would break when receiving and unicode input.
Python 3 became strict, and those two have separate types, and you need explicitly encode/decode string into/from bytes.
This required to fix your python 2 code (ironically if you didn't use unicode type in python 2 chances are you had less to fix).
Since the unicode part was breaking things, Guido also decided to use that opportunity to clean up some warts in python which contributed further.
→ More replies (8)1
Sep 17 '20
There was very little breakage needed. It's very easy to write code that is both 3.x and 2.7 compatible and I did that for a whole project with no hitches at all.
People are simply frightened of changing existing code.
6
Sep 16 '20
It was the other way. Because they supported 2.x for 10 years transition from 2 -> 3 was a nightmare. Since 2.7 was not deprecated, a lot of dependencies didn't support 3 because authors didn't care. It seems like real migration started happening in mid of 2019 and I don't remember reading about any horror stories about it.
3
u/Sector_Corrupt Sep 17 '20
It's not like they announced the 10 year window up front though. It was originally a 5 year window and we only learned about the bumping like a year to go because way too many things were still not ready for python 3. Things were definitely a lot more ready to go in 2019 than 2014 even if most end users still did the migration push mostly right before they had to.
3
u/Eurynom0s Sep 17 '20
5 years was probably still too long and guaranteed that it turned into 10, though.
3
Sep 17 '20
5 years was already too long.
It was also clear that it wasn't even needed, there were two major turning points for Python 3.
2015 - when they announced that no new features will be added to 2.7, that's when packages started to adding Python 3 support, some of them were python 3 only. Before 2015 it was tough to write anything in Python 3, because most libraries didn't support it.
mid of 2019 - right before EOL majority of applications were migrated
IMO if they made it 2 years instead of 10 it would be still enough time and we wouldn't have time for FUD.
7
u/stevenjd Sep 17 '20
IMO if they made it 2 years instead of 10
then Python would be dead and we'd all be using Ruby now.
There are millions of Python developers, over eight million, probably more like ten if you include casual coders, amateurs and students. You are painfully naive if you think that millions of coders will migrate tens of thousands of projects in two years.
This may come as a shock to you, but most coders are more interested in bug fixes and adding new features, especially new features that allow them to bring in more revenue, not just upgrading to the newest version for the sake of upgrading.
A two year transition period would have convinced millions of people that Python doesn't give a shit about the users, and they would have gradually drifted away.
3
Sep 17 '20
It was the other way. Because they supported 2.x for 10 years transition from 2 -> 3 was a nightmare. Since 2.7 was not deprecated, a lot of dependencies didn't support 3 because authors didn't care. It seems like real migration started happening in mid of 2019 and I don't remember reading about any horror stories about it.
Yeah having a 5 year support was a REALLY bad call. I work on a library that is FINALLY end python2 support and it's a really delicate balance of easting the migration, giving enough incentive to make the transition worth it, and make staying on the old version unpleasant enough that people are willing to make the shift. Python did none of those things.
5
u/tlm2021 Sep 17 '20
And it's not "was", it still "is".
The entire VFX/Computer Graphics industry still hasn't moved. And aren't particularly close.
2
u/clawjelly Sep 17 '20
The entire VFX/Computer Graphics industry
You do know that blender is used in some CG companies, right...?
→ More replies (7)2
u/dysprog Sep 16 '20
I still have a project on python 2. It relies on internal libraries that are abandoned by their original creators. I just got permission to work on the upgrade because they can't have what they want with out it. So I am basically tied up until December
2
Sep 16 '20
Yikes and that's even after the EOL. I recently heard that there's a 4 line CVE and they're refusing to even do that. Python 2 is officially a security risk.
→ More replies (1)4
u/flying-sheep Sep 16 '20
Good. People have been dragging their feet for too long. Some scariness might help
1
u/Eurynom0s Sep 17 '20
I had thought that 4.0 would come after 3.9 but that it'd simply be what came after 3.9 (i.e. no different than calling it 3.10).
3
u/WillardWhite import this Sep 17 '20
The naming scheme has implications though. Totally not the same thing
→ More replies (1)1
u/SpiderFnJerusalem Sep 17 '20
And there will still be companies who will keep maintaining their existing Python 2 code in 20 years.
52
u/PirateNinjasReddit Pythonista Sep 16 '20
The transition for python 2 to 3 has been on going for 12 years... Officially python 2.7 reached end of life back in January, but there are still companies and people using it. Basically 2 to 3 was painful. Nobody ever talks about 1 to 2, because it less painful - perhaps in part because the language was less popular.
25
u/ShevekUrrasti Sep 16 '20
I have been trying to get my coworkers to update from 2.5 for more than two years. They still use it and they will continue using it.
And no, nobody is telling them to continue using it. They "just don't like python 3".
54
u/flying-sheep Sep 16 '20
They're dangerous idiots. If a programmer refuses to switch away from something that's EOL and has been announced to be EOL soon in 2008 or so, they're a liability and shouldn't be let into proximity of a production system.
12
u/gregy521 Sep 16 '20
Do they not run into issues when the rest of the world is leaving them behind w.r.t libraries/code examples, or code imported or exported to other companies?
15
u/thornofcrown Sep 16 '20
Someone in my lab wrote a part of our pipeline in Python 2 and I spent probably half of my time working on making that code work with modern data analytics packages. Sucked too, because that person was a way better programmer than me.
4
u/kankyo Sep 17 '20
Being a programmer is also about knowing when to not use bad tools. Failing to do that is not good.
You might mean "clever" programmer. That's not nearly the same thing.
→ More replies (1)6
u/davvblack Sep 16 '20
at some point an ecosystem is rich enough you can't really be "left behind" with all the packages you have available.
7
u/Jethro_Tell Sep 16 '20
If you assume all code has bugs, and it does, then left behind starts to happen as those bugs are found but not fixed.
7
u/davvblack Sep 16 '20
while that is true, think of how many CPU cycles these old-ass python libraries have seen, and how many chances to find and fix these bugs (especially old 2.7 libraries, slightly less true with 2.5).
5
u/stevenjd Sep 17 '20
left behind starts to happen as those bugs are found but not fixed.
A bug that isn't discovered until the code is a decade old or more is probably a bug that isn't cost effective to fix.
Cost of fixing the bug? $$$Big
Extra revenue brought in by fixing it? Nil.
Customers lost by not fixing it? Nil.
Yeah, just work around it.
Also, you forget that porting the code to a breaking new version will almost certainly create new bugs, not fix old ones.
The bottom line here is that once software is mature enough that there are no new features to be added, it becomes legacy software and upgrading it can only make it worse, not better.
Solution: make a VM of the latest OS and Python interpreter that it will run, stick that VM behind a firewall and in a restricted environment, and use it forever as a black box application.
1
u/clawjelly Sep 17 '20
They "just don't like python 3".
People who make decisions on such bases should be flogged in public.
→ More replies (2)1
u/neuronet Sep 17 '20
On the 2 to 3 transition: put your hand in a blender and turn it on for the next 10 years. Be sure to have people nag you about why you turned on the blender. Plot twist: their head is in a blender but they think they have it better.
1
0
Sep 16 '20
[deleted]
8
u/EdamameTommy Sep 16 '20
Nah I don’t think this is it. He’s saying 3->4 would be a smooth transition, unlike 2 to 3. Python 4 would likely be pretty similar to 3
1
u/vallas25 Sep 16 '20
So the step from python 1 to 2 was like they invented a new programming language?
7
u/NoLongerUsableName import pythonSkills Sep 16 '20
I wasn't there when it happened, but according to this article, it was actually pretty smooth, way more so than 2 to 3. So I think he's saying it won't be a very radical change.
148
u/radekwlsk Sep 16 '20
If there is a developer that does not know how semantic versioning works then he has bigger problems to solve than Python updates.
122
u/v_a_n_d_e_l_a_y Sep 16 '20 edited Jan 05 '21
[deleted]
27
u/rossrollin Sep 16 '20
I am one of those users. I suck at programming and cannot program, but I automated the creation and update of cloudwatch alarms for monitoring services at my company using python and boto3. I fucking L O V E python
36
u/netgu Sep 16 '20
News for you, by definition if you develop software you are a developer. Based on your comment it sounds like a bad one who can still get stuff done.
You can't hide from definitions man, if you write software you are a developer.
19
u/toyg Sep 16 '20
it sounds like a bad one who can still get stuff done.
Ah yes, a “devops”.
...
/jk i’m a pretty bad one too.
7
u/rossrollin Sep 16 '20
I am DevOps 😭😭😭😭😭😭😭😭😭 started a job as a platform Engineer today too
→ More replies (1)3
u/rossrollin Sep 16 '20
Well I'm not the kind of developer than can find pi to the nth digit. That stuff hurts my head. I can ensure stability of your infrastructure and 24/7 monitoring and alerting of it though.
→ More replies (3)13
u/SkettiCode Sep 17 '20
I can't find pi to the 4th digit; nor can I write most sorting algorithms. But I can abstract processes into business apps and manipulate data. Developers aren't all CS majors. I appreciate our diversity.
10
u/What_Is_X Sep 16 '20
It's not like C++ or Java which only developers would touch.
/r/arduino suggests otherwise lol
8
u/netgu Sep 16 '20
If you use a programming language, you are now a developer and have to deal with the difficulties of being a developer. Sorry, that is just the way it is.
Python is a programming language and when you write software in it you are developing software as a developer. Period.
Same applies to R and any other programming language. Just because you don't want to learn to be a programmer doesn't mean that you don't need to or aren't just because you use python.
Python has all the same concerns as any other language and needs to be treated as such.
9
u/BelieveBees Sep 17 '20
A discussion about semantic versions turning into a disagreement about semantics. Excellent.
46
u/flying-sheep Sep 16 '20 edited Sep 16 '20
Python never claimed to have semantic versioning though. Some deprecated features are removed every minor release. Also, for a long time, Guido said he didn't like double digit versions and would just release 4.0 after 3.9!
I don't know if that changed when Guido stepped down or before.
2
u/radekwlsk Sep 16 '20
What I've meant is that versions do not overflow after .9, but I might have been a bit more specific there, right.
1
u/flying-sheep Sep 16 '20
You're right about that but there's several versioning formats that work like this, semver only being one of them. Python packages have PEP 440, and many Linux distributions have their own one for their packages.
13
Sep 16 '20
[removed] — view removed comment
→ More replies (1)8
u/flying-sheep Sep 16 '20 edited Sep 16 '20
Well looks kinda like conservative semver with an extra element on the left. I always upgrade as soon as Arch Linux does, since that usually means all breakage is addressed.
4
→ More replies (10)0
13
u/sekex Sep 16 '20
Python 4 will have 2 types of strings: str and String, pattern matching, fearless concurrency and zero cost abstractions
7
u/neuronet Sep 17 '20
Python 4 will cure covid with
cure.covid19(True)It pretty much will be the Chuck Norris of languages.
5
u/sekex Sep 17 '20
Python 4 will write itself. Python 4 won't require a computer to run. In python 4, you will just need to write "money.give(me, 5millions)"
30
u/vswr [var for var in vars] Sep 16 '20
Python 4 = no GIL 🙏 🙏 🙏
32
u/Watthertz Sep 16 '20 edited Sep 16 '20
The GIL isn't part of Python, the language, but CPython, an implementation. Python 3 can be implemented just fine without a GIL.
Edit: I was wrong about Jython supporting Python 3.
7
u/amlybon Sep 16 '20
That's Jython 3? I thought it's only 2.x
5
u/Watthertz Sep 16 '20
Oops, I'm dumb. You're right that Jython doesn't have stable (or any?) 3 support. But the point still stands that the GIL is an implementation detail of a particular implementation and isn't a feature of the language.
3
2
u/james_pic Sep 17 '20
I don't believe anyone has implemented Python 3 without the GIL though.
IIRC, PyPy's STM experiment never supported 3. They also posted a call for funding for a "let's just remove the GIL from PyPy" project a while ago, but I haven't heard much about that since.
And CPython is the reference implementation, which had meant PyPy has had to copy loads of CPython implementation details over the years to maintain compatibility - I imagine even if they do remove the GIL, they'll have to keep something like it in their cpyext code.
1
22
u/remram Sep 16 '20
Some work on performance would be good. multiprocessing is full of gotchas.
Pypy has existed for 13 years now. Ruby and PHP both got just-in-time compilation before Python!
15
u/Erelde Sep 16 '20
Performance is an explicit non goal of cpython, on the other hand one of its stated goals is to keep its source code readable and understandable for programming language students.
10
u/lxpnh98_2 Sep 16 '20
Performance is not exactly a non goal. The main reason for not removing the GIL is that it would affect single threaded performance. Guido van Rossum, said that if someone could remove the GIL without affecting single threaded performance, he would allow it.
7
u/an_actual_human Sep 16 '20
That's an implementation feature. One could make a Python 3 interpreter without GIL. I think it's a thing.
6
u/stevenjd Sep 17 '20
no GIL
Here you go:
It never fails to amuse me how many Python coders argue that the feature that they need more than anything else is removal of the GIL, until you point out that they already have a choice of interpreters with no GIL, then they're all "oh I have these other requirements that are much more important, removing the GIL is not actually that critical for me...".
I'm not saying that everyone who bitches about the GIL is a bad programmer, but in my experience, bad programmers love to blame the GIL for their own poor performing code. Especially those who think that the answer to every problem is "threads".
"Python's sort is crap, so I wrote my own super-fast bubble sort with ten million threads so it can do all the comparisons at once, but the GIL makes it slow."
wink
2
4
Sep 17 '20
Sadly, it looks like removal of GIL will require breaking compatibility.
It's not that removing GIL is actually hard, it is fairly easy, the problem though is that without GIL, python becomes dog slow, and getting it back to comparable speed is very difficult due to current design.
The biggest issue is reference counter garbage collecting and also C library compatibility.
I recommend watching Gilectomy videos by Larry Hastings.
2
u/VisibleSignificance Sep 16 '20
My favorite workaround for GIL would be to run multiple python interpreters in threads and doing zero-copy hand-offs of entire object trees. Too bad it's only a dream.
3
2
u/wltechrepair Sep 17 '20
I’m such a python noob. But love the community. 🤓
1
Sep 17 '20
The language is pretty awesome too. I love how productive I've become with Python.
1
u/wltechrepair Sep 17 '20
I’m learning basics right now. What I like is the ability to import modules. Frameworks in a way, one of the more beautiful programs.
2
Sep 16 '20
I don’t know, our transition from 2 to 3 was pretty painless.
6
u/stevenjd Sep 17 '20
I don’t know, our transition from 2 to 3 was pretty painless.
Once the major libraries started to support 3, most people's transitions were relatively simple. But people on the internet love to throw shade on Python. In most cases that says more about their own skill as a coder and the quality of their code base than the magnitude of the migration.
1
u/ImplosiveTech Sep 16 '20
some people will really say this has never happened before
hmmmmm i wonder if a voxel-based survival game has ever taken that route?
1
u/Muhznit Sep 18 '20
At least Minecraft follows a versioning scheme. The Kingdom Hearts series on the other hand...
1
1
1
1
1
Sep 17 '20
Today I start porting our very last project from 2 to 3. For years management debated whether to discontinue it so the upgrade was always postponed, but it still brings in money so here we go.
1
u/cediddi SyntaxError: not a chance Sep 17 '20
Pattern matching pep is a mess. I never liked := operator. But I like @ operator and many other stuff like async, typing, secret statistics etc. I hope steering council will decide the best.
1
u/goyalaman_ Sep 17 '20
There was python 1?? 😲
2
Sep 17 '20
Maybe I'm missing the joke, but I'm genuinely curious: what did you think came before Python 2?
1
1
1
1
u/goyalaman_ Sep 17 '20
No idea!! I Literally thought Python was the beginning.. I have been using python for years but never.. I really mean never hear the mention of python 1.
1
u/1114111 yield from pedestrians Sep 18 '20
Thank goodness, but was this ever even a question? Having 3.10 be Python 4 would be a total nightmare. In addition to normal semver reasons, Python has the problem that on most systems, python == python2 or nonexistent, so python3 == latest python, so there wouldn't even be a good way to refer to the latest python3-compatible version in shebangs or scripts. If Python 4 ever happens, there had better be a good reason for it.
1
u/bigsexybanana Oct 18 '20
How was python 3 decided from 2? What was the big change? I hope it’s not just bracket compulsion in functions
1
Sep 16 '20
For us new to this what happened? Like I'm 5 if possible
0
Sep 16 '20
[deleted]
→ More replies (1)2
Sep 16 '20
No I meant about what's changing in python. I see talk of "not like the transition between 1 and 2 or 2 and 3" so I'm wondering what exactly they're referencing
0
-7
u/productive_guy123 Sep 16 '20
Why didn’t they refer to the version as 3.09 rather than 3.9
30
Sep 16 '20 edited Sep 16 '20
Because version numbers aren't decimals. The points just separate major and minor versions, and often things like patch versions. There's plenty of software with more than two sections of the version, like 2.15.7. As it happens the app I work on just bumped from a x.x.9 to x.x.10 this week.
Edit: not sure why you're getting downvoted for asking this. It's a totally fair question if you don't have a lot of experience with development.
9
u/duncan-udaho Sep 16 '20
This is correct. It's not a decimal number. It's a version number, probably a semantic version number, which prohibits leading zeros and in fact specifically calls out this case. 1.9.0 -> 1.10.0
2
u/productive_guy123 Sep 17 '20
Thanks for the explanation, I honestly don’t know why though
2
Sep 17 '20
People just like to feel superior I guess. To make the case even better how reasonable the question is: I'm the person who decided our version convention and even decide in most cases how we break up releases into patches and minor versions, so you would think I would be pretty intimately aware of how it all works. I happened to need to write a simple function recently that compared version numbers and my immediate impulse was just to convert it to decimals (with major version being hundreds). I realized right after writing it out that I couldn't count on there being less than 100 patches or minor versions, but it goes to show that even if you are very familiar with it, thinking about it the way you did is totally natural.
33
u/Sw429 Sep 16 '20
Why not refer to it as 3.009 just in case Python 3 has 100 versions? But then what if it has 1000 versions?
It's just too hard to predict. Most version numbering handles this the way python is.
→ More replies (7)9
9
u/PirateNinjasReddit Pythonista Sep 16 '20
What of we do a hundred or so releases of python 3? I.e. 3.420.69 could be a valid release.
6
u/Hamster_S_Thompson Sep 16 '20
That's what the dots are for. You never know how many versions there will be
2
u/NoLongerUsableName import pythonSkills Sep 16 '20
Would create confusion with Python 3.0 bugfix updates like 3.0.1.
1
u/flying-sheep Sep 16 '20
Versions are interpreted similarly to
tuple(int(segment) for segment in version_string.split('.'))They are not floats.
-11
u/NTWK_Identifier Sep 16 '20
3.9 -> 3.10
This makes me irrationally angry.
9
→ More replies (2)3
u/netgu Sep 16 '20
Try this version number on for size:
Eclipse IDE 2020-09-4.17.0
That style is visually jarring for me.
2
u/flying-sheep Sep 16 '20
I like it, it makes clear that this part of the version is a date, by using the one and only date formatting: ISO 8601, a standard so useful that I know its number by heart.
→ More replies (5)
66
u/schplat Sep 16 '20
Which means beware the transition from 4 to 5?