Practical Business Reasons to Upgrade to Python3

Photo by Helloquence on Unsplash

At my company, Devetry, we love Python for its speed of development, ease of use, and ability to abstract the nitty gritty so we can work in higher level concepts. It’s the perfect language for prototyping, but also holds its own as a production grade backend. Many long term projects are written in Python that continue to be extremely successful.

With all the buzz around Python2.7 going end of life January 1, 2020, it might feel like the apocalypse. If you have a project in Python2.7, it won’t cease to function at the end of this year, but it’s time to start thinking about migrating in order to set your company up for success. Here are some of the practical reasons to do so.

Python Support

Python2.0 was released at the turn of the century and Python2.7 as we know it was released in 2010. So, with almost 20 years of development, Python has gone through the wheel with optimizations, bug fixes, and security patches. Python2.7 is a mature and stable language, so there’s an argument to be made for sticking with it.

But with End of Life happening, there will no longer be any official patches released by the Python team. That means new optimizations and functionality will cease to be added and patching security vulnerabilities will be on the onus of linux distros that still need to support a stable OS. Long Term Stable versions of distros also have an End of Life so it’s unrealistic to think they’d spend much time on Python2.7.

If a vulnerability is found in Python2.7 and your application is externally-facing, it would be at risk until the developers of the server OS added a patch. If your application had been upgraded to Python3, however, the security patch would be a high priority and a far larger community of Python users and developers would be on-hand to solve it.

Package Support

It isn’t just the Python team who will no longer be supporting Python2.7, either. Many packages you might rely on, including major packages like Numpy, Pandas, Pytorch, and Tensorflow, are pledging to stop supporting Python2.7 in or before January 2020.

There’s a comprehensive list of packages that will be ending Python2.7 support here.

With these packages dropping support, all new development will be for Python3. If you’re still using Python2.7, you won’t be able to take advantage of any new features, and that could mean leaving a lot on the table. Also, if a package you use has a security vulnerability, you would need to take responsibility for fixing it, which could be an expensive, time-intensive distraction for your developers.

New Features

Python3 brings a lot of new features to the core language. We have another article that explores these in more detail, but here are some of the highlights:

Function annotations. Developers are now able to explain, in the code, what types a function takes and returns. This helps with an age-old Python issue — in Python2.7, for example, when looking at a function, there’s no easy way to know what types it expects and what it will return.

Iterators. Functions in Python2 that generated lists such as lambdas and range() are now iterators in Python3. This is good news, as it helps with a program’s memory efficiency.

Standard Library Additions. These continue to improve utility and functionality for developers. For example, in Python2.7, it can be difficult to work with paths because you have to use the OS module. For Python3, Pathlib has a much easier API and greater functionality for working with directories.

Making the Switch

It should be painless for developers who are used to working in Python2.7 to make the switch to Python3. This means they can take advantage of all the new features coming while still being able to maintain velocity and deliver new features and fixes on their project.

As Python3 slowly diverges from Python2.7 though, it will become harder to attract new developers who are familiar with the Python2.7 codebase or would want to work on one. Developers are drawn toward new technologies, and with all that Python3 has to offer, many would find it hard to settle with working on Python2.7.

Right now, it may be fine to stay on Python2.7, but all the reasons that make it easy to stay on this version will eventually be the reason it’s hard to upgrade. The server’s linux distribution that your code runs on will soon only support Python3 and upgrading your OS will eventually mean upgrading your code as well, making it a hassle to ensure your distros have a Python2.7 environment installed.

The good news is, you still have plenty of time to plan and execute migrating your project from Python2.7 to Python3. If you still need to scope your migration, you can find a helpful checklist here.

CTO at Devetry (www.devetry.com). I write about technology, software development, and entrepreneurship. I also play guitar and love whiskey.