Despite the fact that it only has four years until end of life, Python 2.7 continues to cling on, with downloads far in excess of those for the newer Python 3.x branch. Looking at the situation from a different angle a recent survey concludes that by mid-May Python 3 will be better supported than Python 2.
This finding comes somewhat surprisingly from the Microsoft MSDN blog, where it was posted by Christopher Wilcox, a member of the Python Tools team at Microsoft.
His starts his post with a scenario we've previously outlined on I Programmer that despite Python 3 having been available since 2008 we are:
still looking at a world where people are using Python 2 and talking about how Python 3 doesn’t work for them.
The recurring justification given by those clinging to the Python 2.x branch, of which 2.7 is the very last member, is that the packages they rely on aren't on Python 3.0. However, Wilcox's analysis of the situation reveals that this is often a misfounded belief.
We recently fell into this very trap last week when we criticized Mathics, the new open source symbolic maths package, for requiring Python 2.7. We were quickly corrected - it's latest version can indeed be used with Python 3.3 and above. Even so in order to give it a test run we advise installing Python 2.7 from PyPI!
A recent request for information on Reddit about the current start of Python 2 versus Python 3 downloads elected the following statistics for a two-week period spanning the end of January/beginning of February 2016 based on around 133 million downloads:
Commenting on these figures Pythonista and Python 3 advocate Hynek Schlawack states on his blog:
the Python 3 situation seems gloomy: all Python 3 versions together are about as popular as Python 2.6 that nobody should use anymore.
His conclusions are:
It means we have to write hybrid libraries for PyPI for the foreseeable future.
It means that the PyPI download statistics won’t look much better anytime soon due to sheer numbers of written Python 2-only code and Python 2.7 still growing.
But it also means that Python 3 is growing. A new generation of Python developers likes it and doesn’t understand why anyone would want to subclass
object in each class.
And finally it means that Python 3 is not the death of Python. But we’ll have to live with two Pythons for quite a while. If we manage to not kill each other over it, everyone’s gonna be fine.
Instead of looking at user downloads Christopher Wilcox looked at PyPI data to investigate package maintenance and activity counts arguing:
This way, we get to look at a leading indicator of adoption, the package creation, instead of a trailing indicator, the package download. Using package creation we can find that a world where Python 3 is better supported isn’t far away.
Using this chart Wilcox show that among packages uploaded over the last 5 years Python support is increasing and Python 2 support is decreasing:
(click to enlarge)
He goes on to extract two trend lines that indicate that Python 3 support is converging with Python 2 support:
when run with the data available as of February 22, 2016 the analysis returned a date of May 21, 2016 for Python 3 to be better supported than Python 2. Now, this doesn’t include packages that aren’t classified with trove classifiers. It also gives higher weight to maintained packages. This date seems optimistic but the data is certainly pointing at Python 3 taking over in the very near future.
Another Python 3 advocate, Ian Osvald, whose views we reported on almost two years ago in Python 3.3 Overtakes 2.7 - Time To Switch? discusses another potential trend that could accelerate the adoption of Python 3.x - that of providing free support for Python 3.x while charging for Python 2.7 support.
His recommendations which he points out come from a Senior Industrial Data Scientist with 15+ years commercial experience and 10+ years using Python) are:
- Where feasible – all new projects must use Python 3.5+
- If Python 2.7 compatibility is required – write all new code in a Python 3.5+ compatible way, make extensive tests for the later inevitable migration
- Accept that support for Python 2.7 gets turned off in 3.5 years and that all Python 2.7 code written now will likely have to be migrated later (this is a business cost that you can estimate now)
- Accept that as we get closer to 2020 more programmers (both new and experienced) will be using Python 3.5+, so support for Python 2.7-based libraries will inevitably decline (there’s a big business risk here)
This slide from a recent talk Osvald gave entitled Move to Python 3! summarizes the advantages as he sees them:
Finally there are other signs of increasing enthusiasm for making this move. See for example the post Switching from 2 to 3: Love, asyncio, and more from a Pythonista who, having been riding the 2.x line, was itching to write some Python 3 code.
And, yes, he was impressed.