There isn't a huge amount of win for going to Python 3, but there's plenty of code to change. It's not like Python 3 is 10x faster or has multi line lambdas or something.
Plus Python 2 has been updated many times in the past decade so it's not a maintainance based motivation.
Personally I code against Python 2. There just hasn't been enough motivation to learn 3 and make sure all my third party libraries work with it.
Well now you're getting onto my personal reason why I don't adopt Python 3. Python 2 will remain just as useful as it's been. Python 3 will not significantly extend that usefulness.
So I don't think there's much to be gained.
The 3 syntax and new features are not massively better than the sweet spot hit by 2, they're not even incrementally better. They're just massively more complicated.
So the cost/benefit ratio of Python 2 to 3 just isn't there. People are changing up because it's "the done thing" not because they really gain anything.
I was surprised as hell when I realized I wouldn't use Python 3, but it is a rational and considered opinion.
Except I know plenty of experienced Python 2 users (like myself) who moved to 3.x and like it. The point being made, I believe, is that the only reason to prefer 2 is if you are locked into it for historical reasons.
The differences are small, and all the arguments against 3 are really just 'breaking changes suck' - yes, they do, but it turns out that we aren't perfect and language designs aren't perfect - you either make breaking changes or live with bad designs forever.
Python made those breaking changes - the alternative just means that in X years we'll move to an entirely different language that does things better instead of moving to Python 3, and at least having an upgrade path.
I see you've been downvoted. Interesting, you said that you haven't found a reason to switch and someone looked at it and thought "How dare you not find a reason to switch, here let's teach you a lesson".
But in large I agree. 3 hasn't provided enought of a carrot and 2 hasn't been enough of a pain for many people to want to switch. Especially when it comes to existing stable code bases. For new development, yes, many can and should pick Python 3. But if say Python 3 brought even a 20% speed improvement overwall, the move would have been a lot faster.
I find people are ok with accepting some breakages due to re-writes if either existing stuff is very broken, or new stuff is so much better.
Part of it is that Python 3 does not offer any really strong reasons to switch to it, in an existing code base. It is definitely better and rounds out a bunch of small problems and inconsistencies that exist in Python 2. It also does have some cool new features. However, since Python 3 is not compatible with Python 2 (there is very good tooling for automatic converting and supporting both in one code base) many developers have not taken the time to port their code.
In large part because python 3 just wasn't worth using for the first few (probably five or six) years. The big reason so many of us use python is because of the wide range of libraries and modules that no longer worked.
And when selling it to people, it was usually "Oh, just do X, Y, and Z and you can port this library to Python 3". Not to mention all of the "Just write your python scripts to be backwards compatible".
So, as a user, I saw no reason to push it. A lot of hassle to not even really take advantage of anything to stay backwards compatible. And the moment we found a library that wasn't ported, we were back to 2.x.
Not to mention the zealots who would then explain to me how I was horribly wrong and that my firm is wrong and that we are bad people and blah blah blah blah blah.
These days it is a much easier sell in terms of compatibility as most (not all) major libraries have migrated. My personal work tends to be in python 3 and we try to make our in-house tools work for both (but 2.x is the priority). But most of our users are still going to use 2.x simply because there is no compelling reason to migrate (even if the migration is "Put parentheses after 'print'").
And the zealots are still annoying as hell.
And if 2.x really stops getting supported? I hope we'll migrate to 3, but there will be a lot of research and soul-searching first. Because now there are other languages with similar capabilities and if we are going to have to teach everyone something new, we might as well do it right.
Well, speaking only for myself, if I think of Python 3 as a separate language from Python 2 (which it surely is by now) and ask myself as a sober, grounded, (wannabe) engineer "what do I gain from (re-)writing my code in Python 3?", I gotta say the benefits just aren't there.
There's nothing technically compelling in Python 3. It's all developer candy.
Python 2 is going to remain stable for years, even decades. It's FORTRAN. Development on the C interpreter will stall, but what that really means is that it will become asymptotically bug-free. If no one is touching the code except to apply bug-fixes there are no sources of new bugs (okay bug-fixes will introduce bugs themselves, but the net trend will be negative.)
Even if you have to use e.g. Tauthon (a Python 2 that brings in a few select features from 3) you can still expect a more stable environment than Python 3 development.
And there are a lot of Python 2 runtimes and other places where Python 2 syntax is still welcome: Stackless, Pypy, Cython, Nuitka, MicroPython, Brython, etc... Python 2 hasn't gone anywhere.
Frankly, I think it's a damn shame IMHO that the Python 3 interpreter can't run Python 2 code! Not even with a command line switch. It should be able to switch syntax per module/file at least.
Anyway, to repeat, to me Python 3 is full of dubious toys for developers but has no compelling business value to drive adoption. It's cannibalizing the Python 2 community and ecosystem, but without that nobody would use it. It's not better than 2, just different.
If you were to start a new project and had to decide on a language, you would be better off (IMHO) with Rust or Go (or Python 2) than Python 3, generally speaking.
Let me turn the question on it's head: Python 3 adopters, can you give me a reason, a technical reason, why I should chose P3 over P2 for any project?
I'll throw out some things right off:
Performance. No. If you're using Python and worried about performance you've already committed stupidity and I'm not interested. Cython is your friend.
Async. No. I write Twisted code. Async has been done. Adding keywords to the language is stupid. (As an aside, I know Twisted is hard to use, and the docs sucked until recently, but it is a damn fine code base, written by really good and committed people, and it's an unsung under-appreciated treasure chest! Any Python networking code that does anything serious and doesn't use Twisted is probably doing too much work, poorly. The last thing the language needed was "async" as a keyword. "Foooooootguuuuuuun Jenkins!")
F-strings. No. More stupid and there are dozens of libs that do it.
Support? No. I can maintain the P2 code on my own if need be, but I don't need to because there are others, e.g. Tauthon, etc.. and I can support them. Plus as I said above, with no innovation comes no new bugs!
Type hints et. al. Ummm..., No. I was really stoked about this, but the first time I tried to use it (MyPy) I immediately broke it. I was doing things with the default keyword argument dict that just couldn't be represented in the type language. Valid useful Python code that the types can't handle is a thing. I like strong types, but Python has never benefited from over-nicety in typing. Quack, quack. Put another way, the coercive-type subset of Python is great but overly restrictive. (Which is not inherently bad, I think Elm-lang is brilliant!)
I love Python 2 because it has such a clean syntax, it deals sensibly with all the little fiddly bits that e.g. C makes you think about, and its semantics are powerful and flexible but elegant enough that you can hold the model (or a reasonable homologue) in your head.
From my POV Python 3 just messes up 2. I see no compelling technical reasons to use 3.
i personally don't care too much about how python 2 is still more popular than python 3. it's like saying java 1.5 is more popular than java 8. it just doesn't matter to people who use python 3. after working on a python 3 code base for almost 2 years now i wouldn't go back to python 2 if they paid me for it and there's one reason for that: exception handling. it's something that's just broken in python 2. it's a huge change and your 3) is invalid because of that (and unicode, but you probably don't care if you don't consider this a worthwile change.) your 4) thus doesn't follow. re your point 5), python's current leadership should be commended for creating a language so good that people have no reason to switch from. python 3 is even better, so just start using it for new projects.
But... why? Python 3 has been "good enough" since 3.4. By 3.6, it was markedly better than 2. With the upcoming 3.8, it seems to be better in every way (including performance!).
I loved Python 2 for a long time. It was a beautiful language. But after seriously using 3, I would never go back. As in, I would turn down job offers involving Python 2 in any other context than "we're hiring you to help us upgrade".
Really? It seems to me like a mostly small vocal group is pushing 3. Most people I talk to actually using it heavily in production are ambivalent or actively planning on staying on 2.
Python 3 is exactly how not to do a major language change. They broke enough that porting isn't trivial, and for many programs there just isn't any benefit. Plus the performance noticeably regressed.
What does Python 3 offers in terms of : performance, or
improved libraries, safety, other major improvements to justify spending time switching production code to it, breaking library dependencies (could be transitive as well).
I don't see a company with a large Python code base justifying switching to Python 3. Yeah personal toy Github projects, sure, Python 3 is nice, but it is simply not enough rewards justifying all the downsides of switching for many projects.
Looking back, how Python 3 was handled was a mistake. There should not have been a Python 3 when it happened. It should have happened a lot earlier. But if it was going to happen, it should have offered some drastic benefits -- GIL is gone, LLVM JIT 30x numerical code crunching improvements, integration with PyPy, ... I don't know, awesome new built-in libraries like "requests", Flask integrated in. Things like that.
What do we have instead?, unicode improvements, generator code improvements, a Twisted-like async library (don't get me started on that). Iterator cleanups around dicts... That is just not enough, sorry.
The Python 2 codebase is growing much faster than Python 3, because the Python core developers have lost touch with the fact that its most dedicated users are not web people, but scientific computing users for who the overwhelming choice is 2.7. Anaconda gives you a 3.x choice on its website almost as an afterthought. Theano is half hearted on 3. Bloomberg doesn't even have a 3 access library (goodbye 3.0 for the entire finance sector). Asyncio, one of the so called killer features of 3, looks great but is 10 years too late and is done much better in other languages (goroutines). Python is seriously losing momentum: hey, even Hacker News quickly demoted this story to page 2 precisely because it attracted the usual flood of 2v3 comments causing the comment number to dwarf the score. It's become a controversial and uncool language thanks to this forced 3 story, and the fact that 6 years later in this dog-years world, this issue is still on the table, makes 3 an utter failure.
I predict that 2.7.9.x.y.z will continue well past 2020 and backport any truly useful stuff from 3 because that's much easier than porting 2 code to 3. Or, and the core developers should seriously think about this, they should build 2->3 right into the interpreter so you can run, unmodified 2.7 code on a 3 interpreter (2.7 libraries included), and then pick and choose the 3 features you want yourself.
Because of the amount of work involved in porting my existing Python code. Python 3 doesn't offer any advantages that matter to me, so that's a lot of effort for little gain.
Given that even a relatively inexperienced developer can easily port 2,500+ lines of Python 2 to Python 3 per day, there's really very little reason for anyone to still be on Python 2 regardless of the benefits or lack thereof of Python 3. This is especially true if you're not trying to take advantage of all the performance benefits of Python 3 right away, and are content just to wrap iterators in list() or whatever just to get the functionality working the same without much effort.
Yeah, I don't understand the argument some people have, that Python 3 is bad because it's slightly different from Python 2 and a small amount of their code won't work, so that's why they're switching to a programming language where everything is different from Python 2 and none of their code will work.
but Python 3 is not really an upgrade is it ? it is a very different language and most people who are pushing (downvoting?) for Python 3 dont seem to understand that.
I have zero problems with Python 3 per se - but when the vast majority of the ecosystem is on Py2 and there is no difference in performance... then I see no reason to consider any breakages.
A lot of the problem is that originally the developers of Python made it absurdly difficult to transition from Python 2 to Python 3, and thus the costs far exceeded the benefits. It was historically difficult to write code that ran in both Python 2 and Python 3. If you wanted to transition to Python 3, you had to simultaneously transition every file in your program, every library you depended on, and all libraries they depended on transitively, to Python 3. The "2to3" program was supposed to automate, but this never worked reliably, and cannot work reliably - to do that reliably requires type information that is typically unavailable in Python.
Things have gotten much better, thankfully. Python 3 (and 2) have been tweaked over the years to make it much easier to write code that will work on both Python 2 and 3, and to make it easier to tweak existing code so that it will work on both. As a result, it's possible to transition code a file at a time, or even a portion at a time, instead of the impossible "all at once" transition. Almost no one used Python 3 after it was released, or for a number of years later. Now that the developers of Python have started to make transition practical, people have started transitioning.
Still, it takes real effort to transition to Python 3, and many people have "real work" to do instead of transitioning language versions without any real benefit. "3 is larger than 2" is not a real benefit. A real benefit is something like "this transition will radically increase performance" - and no one is claiming that Python 3 has a real-world advantage like that over Python 2. "Python 2 will eventually be unsupported" is a problem, but no one is providing free money to do the transition, so for many people it's just a fact.
Historically Python has been very good about supporting backwards compatibility and smooth upgrades. I hope that the Python 2->3 transition was an anomaly. You can make changes to languages, but you have to make it easy for users to do the transition.
It has always seemed to me that Python 3 was mainly a fix on the philosophy of handling strings, but that it didn't offered a clear practical advantage for programmers already handling strings with care. I don't think there is a practical reason to upgrade to Python 3 in terms of language design. The reason will be in term of survival as the community seems to be willing to follow the Python 3 movement and official support for Python 2 ends in 2020.
I think it has more to do with that people using Python3 want to write good looking code, and the people still using Python2 are more interested in getting something running quickly and therefore tend to produce hackish code.
Plus Python 2 has been updated many times in the past decade so it's not a maintainance based motivation.
Personally I code against Python 2. There just hasn't been enough motivation to learn 3 and make sure all my third party libraries work with it.
reply