684 points · by alianinfo · 8y ago · 334 comments
- Python 2 support officially ends somewhere in 2020
- most popular packages are now compatible with Python 3
- Python 3.7 performs about as well as 2.7 with future release expected to be better
Although it still took way too long, if you consider Python 3.0 was released about 10 years ago.
I often see this but I think it's a perception from the Internet/web world.
I work for CGI, all (I'm not kidding) our softwares (we have many) are 2.7. You will never see them used "on the web/Internet/forum/network" place but the day-to-day job of millions of peoples in the industry is 2.7.
And we are a tiny focused industry. So I'm sure there is many other industries like us which are 2.7 that you will never heard of.
That's why "most popular" mean nothing once you take how Python is use as a whole. We don't use any of this web/Internet/network "popular" packages.
I'm not saying Python shouldn't move on. I'm just trying to argue against this "most popular packages" while millions of us, even if you don't know it, us none of those.
I made a lot of code conversion from 2 to 3. Most of them took me a couple hours to a few days.
I'm currently working on a 2.7 project that will never migrate because they literally patched the cpython runtime, but you can't freeze a whole community because some will take bad technical decisions or accumulate tons of technical debt.
Now, Python 2.7 will not stops working after 2020. It's just that we, as a community, will stop to pay the price for the ones that didn't move. If you want to stay there, you'll pay a commercial actor for it.
In 2020 centos 6 will stop received updates. Will you go complain that the new RPM are not compatible ? No, either you update, or you pay commercial support.
Ruby and node did it in a few months and told the community to move or die. Nobody complained.
Perl took so long the language has been forgotten.
PHP literally canceled the version 6, and made it taboo.
We gave years, and means, then extended the deadline, and heard nothing but complaining since.
I won't pretend the migration was masterfully executed. The whole 2/3 debacle was painful.
But, it's been since 2008, come on.
That's very well put. But I guess this can happen only with big, important, projects where you can afford to loose/upset some users...
Uh, Ruby’s big compatibility breaking upgrade (1.8 -> 1.9) took more than a few months, it took years for the community to fully move. (Because of Ruby’s pre-2.0 versioning practice, 1.8.x -> 1.9.x was a major version upgrade, and it was actually a more significant one than the 1.9 -> 2.0 update. But lots of people stayed on 1.8 throughout most of the 1.9 period and the transition didn't really complete until late in that period or early in the 2.x period, and 1.8.7 was getting maintenance releases for four years after 1.9.1 stable release.)
You could argue that 2.y is also a different language than 2.x but this is besides the point: as long as there is a compiler for that language and it works (for your definition of works) you don't need to translate your programs in another language just because you have money.
I don’t think that’s a money issue. Python 3 upgrade is not really compelling. You get slower speed - at least until recently -, tests might pass on 3.x, but documentation and edge cases still are better on 2.x, etc. While nothing is really exciting in the 3.x branch.
I was just rambling about "most popular packages" which are only web/network/academic oriented while a huge part of the Python user base don't use them at all. It's just something the "Python community" can't see because most of them are web/network/internet/academic dev (and maybe it explain why they thought it could go well with breaking compat', internet bubble?).
I really want Python to move. I had the opportunity to discuss with some vendors involved in the industry they told me Python 3 switch was a running gag... I hope 2.7 will be such full of security hole my industry will finally do this once for all and stop joking (they will never move on instead), but please stop tell "most popular packages" represent how Python is used as if it was what should been seen, it's definitely not.
TBH, I think Python community give great tools for transition and write close compatible Python 2 and 3 code is not that hard.
Once my industry will be 3+, as a dev, I will love to follow the deprecation period.
EDIT: I love your blog SamAndMax. :D
Since 2008, the automated tooling has vastly improved. I'd bet most of those "few days" issues would either not exist or take hours given today's advances in the automated code translation and new knowledge on stack-exchange.
The web world indeed can rapidly change their entire stack from LAMP to MEAN to Dockerized Q-Basic CGI scripts and load balance their Twitter clone. There's challenges for sure, but pushing updates is simple and quick, and you can always throw more cloud if you run into walls. If your complete platform rewrite fails, just roll the load balancer back over and try again tomorrow.
It's a lot more difficult when your Python application is communicating with a temperamental motor controller over an ancient RS-232 link with AT commands.
There are only ten of these devices in the world, and three in deployment. They perform critical functions, and they need to run 24/7 without failure or human interaction. (Did I mention these devices are remote, and it takes an afternoon to go out and investigate a failure?)
Every single failure results in a few lines of change in the code base. Those lines cost quite a bit -- both time, money, and loss. It's quite stable now, but that stability came at a price.
But haha, what am I talking about? Geez, I've had ten years to move off this "dead" platform. Let's run it through 2to3, or perhaps try a port to nodejs and deploy it tomorrow.
The py2 end of life is supposed to give your manager hard reasons to switch. But if you never use pypi packages and dont interact with the web, you dont need to upgrade, as you don't need to install packages that might be 3 only and you dont have potential for security vulnerabilities.
Somehow, it was the plan[0]. I feel like I wrote about that extensively already way too many times[1].
[0]: (2016) https://news.ycombinator.com/item?id=11502844
[1]: (2012) https://news.ycombinator.com/item?id=4569440
2008-2012 3.x itself being usable.
2012-2016 Libraries getting 3.x support.
2016-2020 Applications geting 3.x support (trac, samba, ansible, etc)
are you sure on that? my laptop (2.7 ghz 4 cores, 16gb ram) would fall behind my desktop (3.8 ghz 6 cores, 64 gb ram) because it would be paging things in and out of ram, but once the models started running (like XGBOOST), py2x was about twice as fast.
I am not stating this with difinity, because I was not trying to benchmark the two. Just that I casually noted my laptop would always finnish running the same code in 1 hour vs over 2 hours on my desktop.
"Most popular" packages, which ones? Most moved a long time ago to Python 3
Basically once 3.7 is out (which is soon), CPython3 will finally be broadly faster than CPython2.7.
Interpreter startup time is still annoying though. I really wonder what the right strategy for addressing that is. Like honestly 2.7 is faster than 3.x, but 2.7 CLI tools still feel silly to use.
Thanks for this!
Do you know of any more longer term, less light Py2/3 benchmarking?
There's Fabric3, MySQL libs that work with Python3 (and Django), futures are a backport of a feature from Python3, uWSGI and BeautifulSoup might be worrying but the site shows mostly green
At this point if the library hasn't been ported to Py3, someone else would have done it for you or abandoned it.
Edit: Thanks for the updates!
The person you replied to said
> most popular packages are now compatible with Python 3
so it looks like you two are in agreement there.
We’re in the process of migrating several keras/TensorFlow-based projects to 3.6, and I’m struggling to get my emacs environment setup to handle Python 2 and 3 code simultaneously.
And if one isn't, then it's another incentive to update it or abandon it.
- 90% of business code is written in Python 2.x
If you do it step-by-step it's not that hard. The worst part was str/binary conversions but afterwards everything was a lot easier and better to maintain.
If your company is big enough you should maintain and keep it up-to-date, not "it just works"(TM) and hope for the best after 10 years. The death of 2.7 was already in the air for years.
If I didn't need to use Python, I wouldn't. Now why I have to rewrite my old code to v3 if it works? Why do I have to waste time with such a stupid thing? All my new code is v3, but why is somebody nagging me about v3 all the time when v3 is full of warts and mindblowing conceptual holes as well, and doesn't really address multi-threading (GIL love forever) etc.? Coming from C++/Java to Python world it was like throwing away a lot of powerful stuff in exchange for faster time to write. Didn't expect that would be dragged down by additional time to rewrite because of some half-baked API-breaking changes.
On the other Python2 support will go away when the community is done with Python2. And that process goes a lot slower than I think most people appreciate. Still, a big vendor changing their defaults helps a good deal with the push.
I recommend this presentation by Victor Stinner at FOSDEM 2018 which talks about it: https://fosdem.org/2018/schedule/event/python3/
Previous versions of python were back-compatible. Java versions stress back-compatibility. I don't know if HN can find any counter-examples, of a language that thrived through an incompatible, code-breaking upgrade.
Python has done everything possible to avoid this fate, by maintaining 2.7. And I'm not even convinced python has gotten away with yet (e.g. kalite, offline khan academy, needs 2.7). RHEL may end up reversing this. Give it another ten years!
Amd the Enterprize is the most back-compatible thing you've ever seen. This change is going to break lots of code, and they will reverse or lose customers.
Of course. Swift 3 is one example. Ruby 1.9, as others have pointed out, is another.
PHP is yet another, and perhaps more relevant because it is close to contemperaneous. It had its "Python 3 moment" with the migration to PHP 5. Lots of BC breakages.[0] That transition took about 3-4 years for most.[1] Most users are now on the current major version, 7, and the remainder on 5 are mostly using its latest release (EOL is EOY). No one uses 4.
[0] https://secure.php.net/manual/en/migration5.php
[1] https://web.archive.org/web/20110720002753/http://www.gophp5...
Ruby qualifies, I'd say. From 1.8 -> 1.9 there were syntax changes, changes to how strings worked and so on. Code written for 1.8 would not in general work on 1.9 and the other way around. While it was possible (sometimes with some extra if statements) to write code that worked on both versions I would definitely call it an incompatible, code-breaking upgrade.
Counter-example: The ruby 1.8 -> 1.9 -> 2.0 upgrade path. 1.9 introduced the whole encoding system, which was a major update at the time. It did break a lot of libraries that handled strings. Still, the change went over fairly quickly, partly because major players in the ruby world (rails) adopted the change. The update also brought clear benefits and it was clearly marked that 1.8 was going to go out of support. There are still some stragglers (centos 6, I'm looking in your direction), but it's clearly accepted that ruby 2.x is the standard that you should be writing code for.
Swift breaks every major version at least but not as often and on a large scale anymore with point releases as with 1.x and 2.x. Has been like that from the beginning and everybody that writes it accepted it.
You reminded me of the java version incompatibility nightmares that once littered the enterprise landscape. If they do that now, it's because their history includes perhaps the worst set of incompatibility jumps of any popular language.
Python had deep problems that could simply not be fixed without BC breaks. The decision was made, and in hindsight it was the correct decision by Guido and other core devs.
Look at PHP, and look what a total cluster of madness the language has become.
* an optional type system without hacks was not introduced (types in comments, really?)
* the GIL was not removed or at least a solid parallelism story was not included, one that would allow Python to use all cores on a system while sharing, if needed, memory
* no true performance improving changes were made; by this I mean stuff that improve performance by an order of magnitude; Python is still way too dynamic and this basically sunk Google's Unladen Swallow and Dropbox's Pyston, at least in terms of worldwide adoption
I say this because I'm a bit worried that long term Python has locked itself into a corner where it will keep getting pushed into as the other languages develop a better developer UX. Python was a bit lucky to catch the ML train but who knows how long this will last. And Go, Kotlin, Typescript, Swift, Julia, Rust even are improving their ergonomics and edging towards Python's core competency.
Being an open community effort gives you a free-pass to make mistakes because you're methodologically sincere. Decisions are made by, and on behalf of, those who use the systems.
Having proprietary interests means you're methodologically insincere: mostly, you sell decisions for the developer but they are mostly for the company.
Agree that there was never a shortage of negative articles about py2/py3 transition. Fairly certain Golang success was down to its advantages more than Python's perception who's use has grown through all this time.
Absent Go, I suspect many current Gophers would've landed on Python. So in a sense, Python lost people to Go. But I've never seen anything to indicate that there was a large migration from Python to Go, and certainly not because of 2 to 3 or public perception--whatever that means in the context of a programming language.
Python 2 is still the mainstay for Data Scientists. I've seen more resistance to moving to 3 there than almost anywhere. Which is pretty funny because it's the easiest code to port assuming your data science libs support 3 (and all the big ones do.)
I think it's more accurate to say that Go ended up with some of Python's potential mindshare, not that it stole a significant amount of existing mindshare.
Pretty sure that's not true. Golang might have taken some from Python web frameworks or command line tools, but that's about it. Python's popularity in scientific computing has only grown over time, and that encompasses a lot of fields and users, not just data science.
The lesson from both Perl and Python is clear: you cannot remove language features - if you do you're creating a new language which has to start from zero in adoption.
https://www.python.org/dev/peps/pep-3113/#why-they-should-go
FTFY. Just think about Perl6, Lua5.3 and VB.NET
I am pretty sure somewhere in this world a miserable soul has to maintain a Ruby1.8 codebase.
Perl isn't as widely used as it used to be. Besides, in spite of the name Perl6 isn't compatible with Perl5 but rather a completely new language.
So you can have Python 2.7 installed for Ansible and 3.6 for your application.
It works! I'm using Ansible via the API in Python 3!
If you're using RHEL, the point here is almost entirely moot. You should never have been depending on system python for anything important anyway. If RHEL replacing Python 2 with Python 3 breaks any part of your code or your company, you have already made a huge shit sandwich for yourself.
The fix, however, isn't that bad. Just start using virtual environments. It will take you a while to unravel hidden dependencies, but it's doable in a reasonable amount of time.
Great! Mostly no problem. The backwards-incompatible changes are few and seem to rarely be used in the projects I've seen.
> PHP <= 7
Totally different story. PHP does upgrade slowly, but many of the backwards-incompatible changes are almost impossible to detect without 100% code coverage. A lot of legacy PHP < 7.x code bases are also going to be lacking perfect coverage.
That said, I think bespoke PHP is less common than people think. The WordPress/Drupal/whatever installations are major drivers of the usage numbers for PHP.
The much bigger upgrade was 4 to 5. We have something like 6 custom C extensions and that was a huge pain.
php7 is a great language though. Worth the pain.
Geofft[1] has a nifty solution but it's not as cross platform as the old tride-n-true #!/usr/bin/env python:
#!/bin/sh """"type python3 >/dev/null 2>&1 && exec python3 "$(readlink -f "$0")" "$@" #"""
""""exec python "$(readlink -f "$0")" "$@" #"""
So what are you going to do? Either way has downsides.
And it isn't like developers really have a lot of power to guide the course of a language. Lua is an excellent example of this. If you want to write a Lua program you probably want to target version 5.1 . The developers have released 5.2 and 5.3 but uptake has been fairly minimal and it's a problem because 5.3 is a Python3 like fork. You can lead but that doesn't mean that anyone will follow. The Python 3 thing could of gone a lot worse (or better) depending on what you think of Python 3.
Ultimately the issue is that different people have different ideas about where a language should go (if anywhere) and no faction of developers or users have ultimate control. It isn't anyone's fault, it is everyone's fault.
Another is that Perl 6 brings in many features from other very disparate languages while making them seem as if they always belonged together. It doesn't seem like Python 3 brings that many new features.
So don't bin those 2.7 books just yet if you want a job at a big co.
To some degree, you may be correct, that there will be companies that refuse to upgrade for many years. By and large, I think most people will start to switch:
* Small orgs will begin to see costs of maintaining legacy code skyrocket as it becomes harder and harder to get 2.7 interpreter support for newer kernels. Those that aren't already transitioning now will eventually bite the bullet.
* Medium orgs will probably be the laggards. They have enough funds to pay someone else to make compatible interpreters for them. Your observation about manager authorization very likely applies here so many probably won't bother to upgrade without an internal skunkworks-style initiative.
* Large orgs will upgrade. Their infosec departments will freak out that an old, "potentially insecure" language is being used, regardless of third party vendor support. I see this a fair bit now in the PHP space; where RHEL supports and backports patches for old, insecure versions of PHP, but the infosec people still can't stand it. These days, infosec is getting more and more pull in every huge organization, so it wouldn't surprise me at all to see them start to treat 2.7—or the old, un-updated packages that are locking someone to 2.7—as a possible attack vector and force a change.
All that said, you are right about jobs. If someone knows 2.7 inside and out, they will start to see higher and higher paying contract gigs over the next 15-20 years. Just like the COBOL programmers saw.
I am super curious what Google will do. The thing to watch is whether Chrome/Chromium (and therefore Node.js) can ever be built without using Python 2.7.
And sure, it'll get better, and finally we have lockfiles (Pipenv), and maybe eventually a proper SAT solver will help resolving dependencies https://github.com/pypa/pip/issues/988#issuecomment-36084645... , aaand gradual typing is nice too, and maybe eventually we'll have a proper async library (python-trio, as asyncio is there, but not low level and/or not ergonomic enough).
Yet Python is free and open, and amazing, and I haven't contributed much other than report bugs, so I'm not complaining, just comparing to other ecosystems.
Among people complain about python package management, I have never heard an argument against Conda other than “I don’t like that they recompile base python”. What’s your reason to discount conda?
[1] https://www.anaconda.com/blog/developer-blog/improved-securi...
It's really irritating in the scientific programming world at the moment because we've had some dependencies take years to get to Python 3 compatibility and are they're now being all holier than thou about it all.
We couldn't even start doing the work until our biggest dependency (which we use in 90% of the code base) was ported to Python 3 and while that's been available for about a year, they weren't distributing it and you had to compile from source to get the Python 3 version - and compiling this particular package, which shall remain nameless, is one of the most difficult compilations I've ever had the misfortune to try. It's notable by it's absence on the UK national supercomputer because of this, for example.
So now, we're trying to port our code to it, but it's likely going to take 6 months to a year to do so. Our day job is doing scientific research, and that's what brings in grant income - so for us, it's not a huge priority to spend all our time working on the switch to Python 3, because we can run everything in a Docker container with fixed dependencies and it should continue to run fine for the next 10 years. It will happen, it's just not the most important thing on our list.
And plus, many projects are maintained by people in their free time, often for free. Of course no one wants to spend a ton of free time redoing everything only to work apparently the same as before.
That's not me saying "don't use virtual environments", just be aware you'll probably need to switch back for some system tools.
Edit: Out of curiosity, I grepped for other system utilities that might have this quirk, and it seems like nearly all Python utilities call /usr/bin/python3 directly, but ten of them (on my system) use `env`. That might be a bug worth filing with the Fedora folks. I can't imagine they want it to act this way when a custom Python is installed. Though it's been that way for at least a couple of releases.
I think Conda allows installing different versions of Python (good) but it doesn't play well with Pip (bad)? Last I tried it also bundled dependencies in its own particular way (ugly)? I think it was more geared towards SciPy and NumPy and other scientific development than towards general purpose programming.
The focus of my current right-now dev work is to teach conda to better understand non-conda-installed python packages so we respect what's already there even if it's not a conda package.
Glad to know that soon enough that will be just a memory :)
Yep. Also allows installing different versions of node or ruby.
> Doesn't play well with Pip (bad)
You can `pip install` things into a conda environment but I forget how it works with globally pip-installed packages. I don't think it plays nicely with virtualenv.
> Last I tried it also bundled dependencies in its own particular way (ugly)? I think it was more geared towards SciPy and NumPy and other scientific development than towards general purpose programming.
Yep, it was made by the maintainers of SciPy and NumPy to solve the problem where you have a python package that depends on a system library written in c/fortran/IDL. For an example in ruby, see the problems people have with charlock_holmes: https://stackoverflow.com/search?q=charlock_holmes
Problem is, if you do 'pip install' in one of the environments, it will upgrade the existing version, but overwrite the conda installed one, which will break your other environment. Often though the official conda packages are lagging behind those on pip, so you have to do this anyway, or use Conda Forge which gets more regular updates or use pip (but carefully uninstalling all the conda installed stuff in the environment first) if you want the bleeding edge.
There's a lot of good reasons Python 2 was stickier than Ruby 1.8.x, the biggest one of which is that Py 2 had had much broader use over a longer time than Ruby 1.8, which meant there were lots of people depending on lots of basically “done” code with non-active maintenance in lots of little but overlapping niches, while Ruby was mostly Rails and a few other big actively-maintained ecosystems that amounted to essentially the whole community.
And the move off Ruby 1.8 still took years, was often bitterly divisive, and with plenty of talk of need to fork 1.8 and continue maintenance because large chunks of the community would never move (which, as with Python, continued even after most of the community had already moved.) It's just that's all a few years back (a lifetime in tech industry time) so most people forget that it happened.
The "2 to 3 dilemma" doesn't exist in my life, even though I use Python on a daily basis. I guess it's because I'm late to the game and I'm not working in a big corp with lot's of legacy code. Or maybe it's the field? I use Python for web stuff and tooling.
Anyway.. in my life Python2 is history. The only time I hear from it is either threads like this one or code examples on old blog posts.
> can someone explain why Python 3 has never replaced Python 2?
I think this is inaccurate. Python3 may not have replaced Python2 for everyone, but it looks like it has replaced Python2 for most projects on github.
Furthermore we have a large base of scripts, owned by many people, that use Python as they would use bash, so changing the default Python on them will be like linking /bin/bash and /bin/sh to /bin/csh.
Only after PSF declared in 2015 that 2.7 is maintenance-only and won't get any new features Python 3 picked up.
Many people say that reason for this is breaking changes, but the truth is people are lazy and they won't do extra work to convert until they get kick in the butt. Other languages did have breaking changes and people move on, because the old version was deprecated.
With Python for a long time not declaring EOL for 2.x people assumed 3.x will never happen and started resisting it. The FUD started and people were afraid of even trying it. It got to the point that someone was planning to release Python 2.8 that would backport all changes from Python 3 except unicode.
https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPytho...
~ ls -las /usr/bin/python
0 lrwxrwxrwx 1 root root 7 Jan 5 02:36 /usr/bin/python -> python3My latest (!) stable Fedora still points at py2:
~ $ ls -als /usr/bin/python
0 lrwxrwxrwx. 1 root root 7 Mar 14 14:36 /usr/bin/python -> python2*The new scripts should just use the right #! string
#!/usr/bin/env python2
There, fixed it.Much like `#!/usr/bin/env bash` for bash scripts instead of `#!/bin/bash` (which won't work on many OSes)
https://github.com/search?q=%23%21%2Fusr%2Fbin%2Fenv+python2...
https://www.phoronix.com/scan.php?page=news_item&px=RHEL-8-N...
This links to the release notes for RHEL 7.5, which was released today, and is a minor release (in RHEL terms).
So, deprecated in RHEL 7.5 as a fair warning to everybody and replaced with Python 3 in RHEL 8.
You'd know this if you had actually read the linked release notes you mention. ;)
(Grabbed the ISO and made sure the above assertions are true.)
That isn't really to say that somebody else won't make packages.
For some reason "replaces X with Y" suggests to me that they swapped one for the other (e.g. /usr/bin/python) which seems error-prone.
Generally, if you are installing your own application you will use a virtualenv with all the packages closed off from the base operating system and dependencies installed with pip (we're all doing this, right folks!?).
The same compilers and tools are used for both, many developers mix the two in one codebase, and use small features from C++ in "C programs" because the compiler allows them to. For example before recent C standards, function overloading by argument types or declaring variables in the middle of a function.
But Python2 and Python3 are way more similar than C and C++.
The first electric computer is about 8 decades ago.