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

News An update on Python 4

Post image
3.3k Upvotes

389 comments sorted by

View all comments

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.

0

u/[deleted] Sep 16 '20

[deleted]

82

u/[deleted] Sep 16 '20

I have prod 2.7....talking to logic written in the 90s.

Kill me.

56

u/[deleted] Sep 16 '20 edited Sep 17 '20

Python3 > Datastage > Python2 > Shell (Kornshell) > Perl written in '99 across servers.

I'll have one kill please.

7

u/clawjelly Sep 17 '20

Nuke it from orbit. It's the only way to be sure.

→ 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.

11

u/lzantal Sep 17 '20

Still maintaining one in production with Python 2.4 and Django 1.3 🙄😬

→ More replies (8)
→ More replies (3)

47

u/[deleted] Sep 16 '20

That was just ascii for trouble imho.

15

u/toyg Sep 16 '20

This joke was not hard to decode correctly.

→ More replies (5)
→ More replies (3)

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

32

u/crossroads1112 Sep 16 '20

Thanks I hate it.

26

u/Brainix Sep 17 '20

My favorite thing about {*()} is that you don't even save any characters over typing set(). 😂

→ More replies (1)
→ More replies (10)

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

0

u/[deleted] Sep 16 '20

[deleted]

→ More replies (13)
→ More replies (6)

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

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.

→ More replies (11)

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 (7)

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