1

Python 3 in 2016

 3 years ago
source link: https://hynek.me/articles/python3-2016/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Python 3 in 2016

17 February 2016

My completely anecdotal view on the state of Python 3 in 2016. Based on my own recent experience, observations, and exchanges with other members of the Python community.

Disclaimer: Anyone who sent you here to argue against Python 3 or for Python 2 hasn’t read past the first paragraph. Take their claims with the necessary grain(s) of salt.

Gloom

Looking at the PyPI download statistics1 of, the Python 3 situation seems gloomy:

VersionDownloads12.7419,227,04023.529,934,42433.420,095,82742.612,178,74453.31,327,58263.6326,967

(Downloads 2016-11-10 – 2016-12-11; compare to February 2016 when 2.6 was more popular than all 3.x together.)

And if my company is any sign, Python 2 applications are unlikely to be ported to Python 3. Why should they? Python 2 is officially supported until 2020. Who knows whether the app will exist in that form by then.

The number of these applications is huge. And this number won’t decline significantly in the foreseeable future. Nobody wants to touch their working systems2.

Update: Some actually do! Like Instagram who moved their Django and Celery fleet to Python 3.6 as they described in the PyCon US 2017 keynote. They share some road blocks and solutions thereof in the talk and they’re pretty happy with the result (including memory and CPU improvements).

The Very Gradual Improvement

But.

The vast majority of important libraries on PyPI are hybrid: they support both Python 2 and 3. It’s very rare that someone releases a Python 2-only library nowadays (I’m rather seeing occasionally the opposite and so does Microsoft).

New projects and applications are started frequently3 in Python 3. For example, Patreon moved from PHP to Python 3. Why not? Unless you intend to use PyPy (and some rare low-level unicode edge cases aside) it’s objectively the nicer language. How often are new projects started? In the days of micro services more often than one’d think.

Given the state of the libraries, choosing between Python 2 and 3 is a matter of personal preference and company policy rather than technical reasons.

Especially community members that joined us later and don’t have such an ingrained antipathy to Python 3 find it natural to use Python 3. I’ve seen that both in the Twisted and the Pyramid communities. People have been trying to use Twisted on Python 3 long before it was fit for it. Django – one of the main entry drugs to Python – by itself did a dent in Python 3 usage by using its syntax in their documentation.

Now remember what enormous growth the Python community had in the past months and years. At some point those people are going to be in charge while the old guard yells at clouds. This transition has already begun.

Most educators already teach Python 3 (notable troll aside):

@hynek more anecdote: kids in UK learn Python3 - it's the standard promoted by @Raspberry_Pi & soon #BBCMicroBit via @Micropython. #longterm

— Nicholas Tollervey (@ntoll) February 17, 2016

@hynek I teach only Python 3 at @treehouse

— __❤__ (@kennethlove) February 17, 2016

If you wonder what people actually use, PyCharm tweeted their statistics:

#Python 3: 50%, 2: 65% (overlap), 3 outgrows 2 by 2017-12 (source: @PyCharm stats) contrary to @zedshaw claims in https://t.co/E470kVLq5x pic.twitter.com/CFvTddQnhZ

— Andrey Vlasovskikh (@vlasovskikh) November 24, 2016

Statistics about IDE users are obviously biased towards new programmers but that’s exactly the point.

June 2017 Update: turns out they crossed 6 months earlier than anticipated.


Interestingly, the various sub-communities are coping differently. For example the scientific community is way ahead of the average which in my humble opinion is due to the huge influx of new users in recent years. IPython/Jupyter even intends to release a first major Python 3-only release (6.x) in 2017.

asyncio is another interesting topic. I was surprised how alive and well that little corner of the Python community is (albeit mainly in Russian speaking countries 🙂). Deservedly so I may add. So I’m not surprised that Python 3.4 was the first one with serious adoption.

If you look closely, there are also plenty big companies focused on Python 3 porting. Red Hat has ported their Python tools to Python 3. OpenStack is almost done. Facebook is very outspoken about Python 3, has a policy of starting new projects on Python 3, and runs Python 3 on every single server:

@IsraelFruchter @hynek @d0ugal @VictorStinner Python 3.5.2 is running on literally every server.

— Łukasz Langa (@llanga) November 27, 2016

Did you know that Patreon runs on Python 3 and Flask?

Conclusion

What does all that mean?

It means we have to write hybrid libraries for PyPI for the foreseeable future4.

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.


We for one start all our new projects in Python 3.5 nowadays and don’t want to go back. So stop arguing about it and join us. I think you’ll like it.

Footnotes


  1. Those numbers have to be taken with a grain of salt anyway. Mirrors, caching, system packages, et cetera skew them in unpredictable ways. Interestingly, I’ve been told that macOS wheels for NumPy are above 30% for Python 3. For scientific packages, this information is much more telling than sheer download numbers. ↩︎

  2. Even though porting to Python 3 with a good test suite is not a big deal. But few have good test suites and even fewer have incentives to invest any time into it. ↩︎

  3. Sorry, I can’t quantify this. It’s just the general sentiment that I hear around me. One of the biggest problems of this discussion is that it’s virtually impossible to quantify anything. ↩︎

  4. Although I’d like to invite you to join me dropping Python 2.6. ↩︎


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK