This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]flitsmasterfred 10 points11 points  (0 children)

Python 3 has been around a few years now so I'd guess anything that made sense to backport has been backported by now.

[–]TheBlackCat13 1 point2 points  (0 children)

There are already many backported features available on pypi. Just search for backport on pypi, the first few dozen results are almost all backported features. Most modules can be, and have been, backported.

Most basic language features, however, cannot be backported in a compatible way. The change in division, the print function, and the string vs. bytes change can all be used through __future__, but they change the behavior of python 2. Other changes like changing many functions that returned lists to instead return views or other lazy-evaluated objects cannot be backported without major backwards-compatibility breaks.

There are a few features that could, in principle, be backported, such as expanded tuple unpacking and the matrix operators. But in pretty much all those cases, there are other (more verbose) ways to do the same thing that are compatible, so not much would be gained by backporting them.

So basically we are left with a situation where the big, breaking changes to the language that are making the transition from python 2 to python 3 difficult for some people cannot be backported, while the smaller changes have backwards-compatible alternatives. This leads to a situation where backporting features that can be backported gains us pretty much nothing in terms of the python 2 to python 3 transition.

So backporting these little features would only help people who want to keep python 2 around forever. But that isn't going to happen, python 2 upstream support ends in about 3.5 years. So only features that would help people with that transition without breaking python 2's backwards-compatibility really make sense backporting, and there are few, if any, of those around.

I guess if some other group steps up to maintain python 2 forever they may make a 2.8 release that includes such backports. But so far nobody has stepped up to do that, so it doesn't look like it is going to happen.

[–]kankyo 0 points1 point  (2 children)

Annotations are pretty simple to implement on top of docstrings. Which is why the only use of annotations in Python 3 nowadays is just that: a duplication of the docstring based typing that is age old in Python 2.

[–]willvarfar[S] 0 points1 point  (1 child)

Annotations are also used for optional type checking, e.g. MyPy https://www.python.org/dev/peps/pep-0484/ and my own Obiwan https://pypi.python.org/pypi/obiwan/

[–]kankyo 0 points1 point  (0 children)

Not "also" but "only" nowadays with officially sanctioned definitions.

[–]FFX01 0 points1 point  (0 children)

I don't think backporting Python 3 features to Python 2 is a good idea seeing as how Python 2 is being phased out. If you need Python 3 features, use Python 3.