r/Python • • May 27 '14

Python 3 is fine | Sealed Abstract

http://sealedabstract.com/rants/python-3-is-fine/
234 Upvotes

96 comments sorted by

View all comments

Show parent comments

0

u/[deleted] May 28 '14

Well, they are shooting themselves in the foot if that's what they are thinking.

A lot of people do claim they stay on Python 2 because Python 3 doesn't offer any incentive to move, so that's why they are thinking like that, I'd guess.

Python is a platform, which means that it derives its value not directly from the applications to which it gives value, but through libraries. Which makes migration pretty awkward, since libraries must support both versions for quite a while until most applications have migrated.

Right. And having more new features in Python 2 is not going to change that.

Because you want people's libraries to be written in Python3 and backported to Python2, not remaining a Python2 codebase on which 2to3.py and a bunch of custom patches is run once a month.

That's really only relevant if you still want to support Python 2.5. Otherwise you don't use 2to3 anymore, but use a common codebase.

Yes, if you want Python 2 support, then you can't use the Python 3 only features. But that is only a problem for people who are already mainly using Python 3, and then afterwards discover that Python 2 might be nice as well. And that is currently a very small group of people.

I can't be bothered to install Python3 in order to remove all those from future import's and compatibility libraries and stuff that I added to be compatible with Python3, I'm just fine with awkwardly using Python3 features in Python2.

Huh? I'm sorry, that makes no sense.

  1. You don't need to remove the things you added to be compatible with Python 3. I'm not sure what you are trying to say with that.

  2. If you added things to be compatible with Python 3, you presumably installed Python 3. How else would you know that you are compatible?

3

u/moor-GAYZ May 28 '14

A lot of people do claim they stay on Python 2 because Python 3 doesn't offer any incentive to move, so that's why they are thinking like that, I'd guess.

Nope, most people have no problem installing the latest 2.x version, outside of rare corporate environments. I've never seen anyone discussing whether Python2.7 is killing Python, compared to the Python3 migration this is a complete non-issue, a red herring.

What people who say that Python 3 doesn't offer any incentive to move mean is that it doesn't offer enough incentives to overcome the significant hurdles. Remove the hurdles and this objection would disappear.

libraries must support both versions for quite a while until most applications have migrated.

Right. And having more new features in Python 2 is not going to change that.

This is going to make supporting both versions much less painful.

That's really only relevant if you still want to support Python 2.5. Otherwise you don't use 2to3 anymore, but use a common codebase.

Which is painful, otherwise we wouldn't even have this discussion.

I'm not talking about backporting all new features, I'm talking about backporting all backward incompatible changes and changes required to write basic Python3 code, to be enabled with from future import, ideally including renames and everything that six.py takes care of.

The idea is that a library maintainer should be able to port his library to Python3, then insert "from future import py3_compatibility" and have it running on Python2.7 and Python2.6, whatever they used before, with no further code changes. If that were possible then the whole Python3 migration conundrum simply would have not existed.

The only choices that library maintainers would have to make is whether to use actual new Python3 features, same they have to make re: collections.namedtuple wrt Python2.5 compatibility etc. That would be their private business and have no effect on Python3 adoption.

"I can't be bothered to install Python3 in order to remove all those from future import's and compatibility libraries and stuff that I added to be compatible with Python3, I'm just fine with awkwardly using Python3 features in Python2."

Huh? I'm sorry, that makes no sense.

Well, you said that backporting Python3 features to Python2.8 where they are enabled with from __future__ import and compatibility shims "would lessen the incentive to move to Python 3". So there's this guy who writes de-facto Python3 compatible code using all that stuff but refuses to move to actual Python3. That makes no sense, my point exactly.

0

u/[deleted] May 28 '14

A lot of people do claim they stay on Python 2 because Python 3 doesn't offer any incentive to move, so that's why they are thinking like that, I'd guess. Nope, most people have no problem installing the latest 2.x version, outside of rare corporate environments. I've never seen anyone discussing whether Python2.7 is killing Python, compared to the Python3 migration this is a complete non-issue, a red herring.

What? I don't understand the relation to what you and me said before.

That's really only relevant if you still want to support Python 2.5. Otherwise you don't use 2to3 anymore, but use a common codebase. Which is painful, otherwise we wouldn't even have this discussion.

Going up in the morning is painful. It's all relative. Using the common codebase for Python 2.7 and Python 3.3 is not really very painful.

I wrote Pyroma for Python 2. Then I added Python 3 support with 2to3, with almost no changes. Later I decided using 2to3 was silly, and went onto a common codebase. Here's the changeset:

https://bitbucket.org/regebro/pyroma/commits/b81cbe0085ff0bb71fd048b011808a5aee616867

When I wrote Hovercraft, I wrote that for Python 3. There are reports that it works under Python 2 as well, if you just add argparse as a dependency. So it seems to work with no changes. I just wrote in a "common codebase" automatically.

It's really not very painful. Especially if you use six. The common codebase is pretty much Python 3 coding, with some future imports, and lacking some of the new Python 3 features like "yield from".

I'm not talking about backporting all new features, I'm talking about backporting all backward incompatible changes and changes required to write basic Python3 code, to be enabled with from future import

So in fact, what you are talking about when you say "new features" is "not new features". Yeah. That was clear. I have previously answered you as if you actually meant "new features", which is where much of the confusion is.

The question then becomes exactly what incompatible changes you want to backport.

ideally including renames and everything that six.py takes care of.

Sure, but then again, you can just use six for that. So that's not an actual hurdle, and you mentioned hurdles. ;-)

1

u/moor-GAYZ May 28 '14

Sure, but then again, you can just use six for that.

It sucks to use six.iteritems(d) and the like.

0

u/[deleted] May 28 '14

Well, it's ugly, sure. "Sucks", maybe not.

And that is an interesting example, because what do you want Python 2.8 to do about it, specifically?

1

u/moor-GAYZ May 28 '14

Well, it's ugly, sure. "Sucks", maybe not.

So the problems with Python3 adoption are caused by something else or don't exist?

And that is an interesting example, because what do you want Python 2.8 to do about it, specifically?

That's an interesting question, now that I think about it. I guess a dirty hack to make such objects present different methods to code compiled with that from __future__ import. It can break inheriting from them, but so would a milder method (implement .itemview() etc). Still, it would work for 99.99% of the code and more or less cleanly break for the rest.

Or maybe for that using something like "six" was inevitable.

Anyway it would have been even nicer if this stuff were implemented in 2.6.0 five years ago, before the 3.0 release actually. Then we'd all be using 3.x by now. Unfortunately, the Python core developers apparently believed that they could achieve a clean jump from 2 to 3 somehow, the idea that people would have to make code that works in both never crossed their minds. Thus the dances with unicode literals etc.

0

u/[deleted] May 29 '14

So the problems with Python3 adoption are caused by something else or don't exist?

The slow Python 3 adaptation is NOT because dict.iteritems() is gone, no.

That's an interesting question, now that I think about it. I guess a dirty hack to make such objects present different methods to code compiled with that from future import.

Right, what is the future import supposed to do? Have different dict types? Make the type behave differently in that specific module? (That's tricky at best.)

The only option there was really to change the behavior of dict values, and hence break backwards compatibility. This is one of the changes that can't be done in a good backwards compatible way.