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

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.