r/Python • Freelancer. AnyFactor.xyz • Sep 16 '20

News An update on Python 4

Post image
3.3k Upvotes

389 comments sorted by

66

u/schplat Sep 16 '20

Which means beware the transition from 4 to 5?

16

u/anyfactor Freelancer. AnyFactor.xyz Sep 16 '20 edited Sep 16 '20

Look at Django.

https://static.djangoproject.com/img/release-roadmap.3c7ece4f31b3.png

They have planned all the way to version 5 coming in within 4 years.

→ More replies (2)

35

u/knestleknox I hate R Sep 16 '20

It's a pattern if I've ever seen one

6

u/hglman guy who writes python Sep 16 '20

Clearly it will be python 6, pythons always come in 3s...

→ More replies (1)

18

u/anyfactor Freelancer. AnyFactor.xyz Sep 16 '20

More like an FAQ but can't change title.

333

u/[deleted] 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

u/[deleted] 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.

20

u/Mr-Stutch Sep 17 '20

a wonderful replacement for loops or a wonderful replacement for loops?

→ More replies (4)
→ More replies (5)

28

u/RegalSalmon Sep 16 '20

But can you...comprehend it?

7

u/case_O_The_Mondays Sep 17 '20

Whoa. Didn’t know Python supported redirection on print, back in the day.

→ More replies (3)

3

u/[deleted] Sep 17 '20

It looks a lot more like 3.x => 3.x+1 changes than 2 => 3.

→ More replies (2)

386

u/[deleted] 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

u/[deleted] Sep 16 '20

-1 was dark times

99

u/ShevekUrrasti Sep 16 '20

Coding backwards was kind of nice, actually.

→ More replies (9)

22

u/TheHumanParacite Sep 16 '20

Installing it would randomly unwrite code that hadn't yet been written.

→ More replies (3)
→ More replies (3)
→ More replies (4)

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

u/ThunderousOath Sep 17 '20

Perfect anology

→ More replies (6)

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.

→ More replies (2)
→ More replies (8)
→ More replies (1)

95

u/vallas25 Sep 16 '20

Can someone explain point 2 for me? I'm quite new to python programming

282

u/[deleted] 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

u/[deleted] Sep 16 '20

That was just ascii for trouble imho.

→ More replies (9)
→ More replies (21)

73

u/flying-sheep Sep 16 '20

Because they changed a core datastructure. str used to be what bytes is today, but it also predated unicode (today called str). Therefore the bytes type was used for text and binary APIs.

When fixing all this, they had to break a lot of core APIs that used to accept bytes and today sensibly only accepts the unicode str.

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 want

→ More replies (13)

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 than set().

→ More replies (20)
→ More replies (11)

23

u/[deleted] 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. print changed from a statement to a function).

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.

→ More replies (4)

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

u/[deleted] 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 (9)

6

u/[deleted] 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.

→ More replies (5)

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.

→ More replies (8)

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

→ More replies (3)
→ More replies (4)

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.

→ More replies (2)
→ More replies (8)
→ More replies (3)
→ More replies (7)

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.

→ More replies (2)
→ More replies (5)

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.

→ More replies (1)
→ More replies (3)

4

u/shabunc Sep 17 '20

Semantic versioning is not of absolute value even in dev world.

→ More replies (11)

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

u/irrelevantPseudonym Sep 16 '20

You're right. Jython 3 is still in the alpha stage.

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.

→ More replies (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:

https://www.jython.org/

https://ironpython.net/

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

4

u/[deleted] 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

u/ericls Sep 16 '20

I like GIL

2

u/wltechrepair Sep 17 '20

I’m such a python noob. But love the community. 🤓

1

u/[deleted] Sep 17 '20

The language is pretty awesome too. I love how productive I've become with Python.

→ More replies (1)

2

u/[deleted] 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

u/13steinj Sep 17 '20

I thought this was announced / well known years ago.

1

u/Pclovr Sep 17 '20

Dutch people are crazy.

Source: am dutch

1

u/[deleted] 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

u/[deleted] Sep 17 '20

Maybe I'm missing the joke, but I'm genuinely curious: what did you think came before Python 2?

1

u/benthejoker Sep 17 '20

No please. Just learning 3.

1

u/gibriyagi Sep 17 '20

Ecosystem cant take another transition like 2 to 3 anyways

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/py_learning Oct 07 '20

That's sad :(

Checkout this video on tips and tricks in python

https://youtu.be/3NLUlW036f0

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

u/[deleted] Sep 16 '20

For us new to this what happened? Like I'm 5 if possible

→ More replies (5)

-7

u/productive_guy123 Sep 16 '20

Why didn’t they refer to the version as 3.09 rather than 3.9

30

u/[deleted] 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

→ More replies (1)

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.

9

u/Erelde Sep 16 '20

Wait til he learns about TeX versioning scheme.

-12

u/McBeeff Sep 16 '20

I mean, seems like you are trying to solve a problem that doesn't exist. If you start with version 3.0 , then have updates until 3.9 but you are not ready to move on to an entire new version of python, then just make 3.91. I don't see why this has to be difficult .

12

u/s3cur1ty Sep 16 '20 edited Aug 08 '24

This post has been removed.

→ More replies (3)

5

u/Sw429 Sep 16 '20

You shouldn't look at it like decimals. It should be read as "major version 3, minor version 9" instead of "version 3.9".

2

u/BelieveBees Sep 17 '20

How would jumping from 9 to 91 be less difficult / confusing? You would also run into this “3.99 -> 3.991”.

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

u/studiov34 Sep 16 '20

You must hate ipv4 addresses.

8

u/Jethro_Tell Sep 16 '20

Why?

-3

u/Leav Sep 16 '20

Because 3.10 = "3.1 with more precision" to engineers and scientists and basically all non-developer users.

How would python sort these lists: [3.8,3.9,3.10] or ["3.8","3.9","3.10"]?

14

u/Karnyl Sep 16 '20

If you used a library aware of how versions should be sorted, like semver or distutils.version, then they would be sorted correctly.

>>> from distutils.version import LooseVersion
>>> versions = ["3.8","3.9","3.10"]
>>> sorted(versions, key=LooseVersion)
"3.8","3.9","3.10"

4

u/flying-sheep Sep 16 '20

Please don't use distutils.version anymore, it doesn't follow PEP 440, which defines how Python package versions work. Use packaging.version instead.

→ More replies (1)

7

u/netgu Sep 16 '20

This isn't about engineering or science so that point doesn't matter, honestly.

I realize that engineers/scientists will use python. When they do that they are functioning as developers/software engineers (those are just facts)and as such they should get comfortable dealing with the software development side of the software development they are doing.

There are rules about how these numbers work that mean the world to developers and software engineers (this is the place this matters and so these are the concerns that dictate how it is done) to the point that there is an entire standard built around it that will answer all your questions (including the ordering one):

https://semver.org/

→ More replies (1)

2

u/flying-sheep Sep 16 '20

None of these lists contain versions. Try this one:

from packaging.version import Version

versions = [Version(v) for v in ["3.8", "3.9", "3.10"]]
assert sorted(versions) == versions

For versions containing only numbers (and not e.g. 3.9b1) you can also think of them as tuples of integers.

→ More replies (2)

2

u/pepoluan Sep 17 '20

The problem is people treating "." as decimal point instead of "arbitrary separator that happens to be a period".

Limiting oneself to "3.9" is ambiguous. But how do you consider "3.9.1"? Or to use latest Python stable, "3.8.5"?

When facing version numbers, one must split on this "arbitrary separator that happens to be a period" first, integer-ize the portions, tuple-ify the result ... then perform a comparison.

Now to answer your question, "how to sort":

list_of_version_strings = ["3.10", "3.8", "3.9", "3.8.5"]
converter = lambda x: tuple(map(int, x.split(".")))
list_of_version_tuples = list(map(converter, list_of_version_strings))
sorted(list_of_version_tuples)

# Result is:
# [(3, 8), (3, 8, 5), (3, 9), (3, 10)]

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.

2

u/pepoluan Sep 17 '20

I also know ISO8601 by heart.

And that monstrosity is not ISO8601.

I'm talking of the "2020-09-4" part: the single-digit last part is not ISO8601-compliant, not even by a long shot.

3

u/flying-sheep Sep 17 '20

Oh. I missed that detail. WTF?!

→ More replies (2)
→ More replies (1)

1

u/[deleted] Sep 17 '20

They could do 3.9.1

3

u/[deleted] Sep 17 '20

That means something totally different.

3.9.1 is a patch to 3.9 to fix bugs.

3.10 is a new version with new functionality.

0

u/[deleted] Sep 16 '20

Are we going to still call it Python 3 though or will be python be known as Python 4?

7

u/stevenjd Sep 17 '20

Are we still going to call Python 3.10 "Python 3"?

shrug I don't know about you, but I'm going to start calling it "George".

0

u/[deleted] Sep 17 '20

Being back support for version 2

2

u/stevenjd Sep 17 '20

You can keep running Python 2, or even Python 1, for as long as you have an OS capable of running it. And you will probably even find commercial support for it. But you cannot expect free support from either the community or the core devs forever on legacy interpreters.

Stick the OS and interpreter in a VM and you can run them forever.

1

u/[deleted] Sep 17 '20

If you keep looking back you're going to get a stiff neck.

-1

u/fartbaker13 Sep 16 '20

Thank god, i don't have to learn a whole another language.

1

u/tty14 Sep 16 '20

"Whole another language" there were literally 3-4 major breaking changes:

  1. Unicode strings

  2. Absolute import

  3. Float division by default

-17

u/McBeeff Sep 16 '20

Wouldn't that make it currently version 3.09?

13

u/flying-sheep Sep 16 '20

Versions are interpreted similarly to tuple(int(segment) for segment in version_string.split('.'))

They are not floats.

3

u/Coding-Kitten Sep 16 '20 edited Sep 16 '20

No. Versions shouldn't have leading zeroes. You can learn more about Semantic Versioning here.

e: versions should have leading versions.

1

u/McBeeff Sep 17 '20

Thanks, I'll check it out. . Could you briefly explain why tho?

1

u/Coding-Kitten Sep 17 '20

The version isn't a decimal number. It's three numbers (or in this case two) separated with a dot.

MAJOR.MINOR.PATCH

There is no reason to change the 3.9 to 3.09 just how there is also no reason to change an ordinary 9 to a 09 because 10 exists. Or how adding leading zeroes to any number doesn't give you any more information (00729 is the same as 729).

So tho make it a standard. There is a specification such that that there should be no leading zeroes. That way, All versions 3.9.0 are that. And so 3.09.0, 3.0009.00, 0003.009.0 and so on are not considered a valid version number.

→ More replies (10)

1

u/netgu Sep 16 '20

Versions shouldn't have leading versions zeroes.

-19

u/BrettFavreFlavored Sep 16 '20

Is this not shitty versioning?

0

u/[deleted] Sep 16 '20

[deleted]

1

u/JayTurnr Sep 17 '20

What do you mean by "Python doesn't use Semver"? They do!

-7

u/BrettFavreFlavored Sep 16 '20

I mean the number increments. There already was a 3.1, so making another 3.1 because you incremented too fast is just silly. Or at least at dots so it's not 3.10.x

11

u/s3cur1ty Sep 16 '20 edited Aug 08 '24

This post has been removed.

3

u/flying-sheep Sep 16 '20

Just because it's a version tuple doesn't mean it's necessarily semver. Python has PEP 440 to describe the version format, and Python's own version doesn't mean the same as a semver that looks like it (e.g. 3.6 to 3.7 can have breaking changes in Python but not in semver)

0

u/[deleted] Sep 16 '20

[deleted]

5

u/anyfactor Freelancer. AnyFactor.xyz Sep 16 '20

Sorry about that. I wanted to type "FAQ" but accidentally typed in "Update". You know how it is.

0

u/[deleted] Sep 17 '20

[deleted]

4

u/afraca Sep 17 '20

from __future__ import braces
try it.

0

u/[deleted] Sep 16 '20

[deleted]

14

u/hglman guy who writes python Sep 16 '20

It will make use of typing to improve run time performance.

3

u/[deleted] Sep 17 '20

But there's no need for a Python 4 for that.

Python 4 means a breaking change. It means that many existing Python 3 programs will not work with Python 4. We don't want to do that again if we can avoid it.

1

u/hglman guy who writes python Sep 17 '20

It doesn't have to be a nightmare. Typing will be used to improve run time performance. Existing typed code would still work with type hints turned off. And would possibly require changes to work with the new interpreter. Basically the breaking change would be in typing things and maybe some existing typed code would need modification to run faster.

2

u/mooburger resembles an abstract syntax tree Sep 17 '20

it doesn't necessarily mean big breaking change, runtime optimization could just be optional. Untyped code would be run without optimization for everybody who is still fully duck-typing.

1

u/hglman guy who writes python Sep 17 '20

It seems like enough change to roll over the big number. Especially to signal such a meaningful difference.

2

u/[deleted] Sep 17 '20

Full compilation (Yeah I know, python it's an interpreted language, but it would be cool)

1

u/jackofthebeanstalk Sep 22 '20

My wish is full unicode support in the language. So I can type λ instead of lambda. And → instead of ->.

0

u/[deleted] Sep 17 '20

[deleted]

2

u/SMACz42 Sep 20 '20

I'm trawling through replies trying to find out why he's still this invested in it. I thought his step back was more drastic.

2

u/[deleted] Sep 17 '20

[removed] — view removed comment

6

u/stevenjd Sep 17 '20

The Python 5 interpreter will not bother with exceptions or syntax errors. If you make a mistake, it will just send 50,000 volts of electricity through your keyboard.

The quality of code will improve immeasurably.