With the clock ticking for Python 2 programming language, the cloud storage company Dropbox has detailed why it chose to move to Python 3 programming language and how it made the switch.
The fast-rising popularity of Python among developers shows little sign of abating, due largely to its use in the booming field of machine learning.
However, beyond Python's appeal for data science, fans of the language say its success also stems from its broad range of robust software libraries and how easy it is to learn.
Today there are two main branches of the Python language in use, Python 2 and 3. While 3 is obviously more recent, it isn't compatible with earlier versions of Python, and many organizations have kept using Python 2 to preserve interoperability with legacy code.
However, over time the arguments for switching to Python 3 have mounted up, with most of the major software libraries now supporting Python 3, which also sports a significant list
of improvements over 2, while support for Python 2 is due to end in 2020.
Here are five reasons Dropbox highlighted for choosing Python 3 over Python 2.
1. Python 3 makes developers more productive
Dropbox singles out the availability of type annotations in Python 3 as one of the most important changes.
Python 3.5 supports type hints, which make it easier for code-checking tools to pick up errors and make recommendations for changes to code before it's compiled, as well as helping developers to more easily understand how to work with other people's code.
"Our codebase is quite large, so the ability to use type annotations has been important to developer productivity," says Dropbox in its blog post.
2. Python 3 makes for cleaner multi-threaded code
When running software you don't always know how long it will take for data an app needs to be ready to be processed, for instance how long it will take for a web API to respond to a request. To avoid having the app freeze until the data is ready, and allow the program to continue to handle other tasks while waiting, programmers can use Python's co-routines
support. These features can also be used for simpler multi-threading, a technique for making apps more efficient by having them execute multiple tasks concurrently.
"We rely heavily on threading and message-passing - through variants of the Actor pattern and by using Futures - to build many of our features," says Dropbox, who praised Python 3's co-routines function syntax.
"The asyncio project and its async/await syntax could sometimes remove the need for callbacks, leading to cleaner code."
3. Python 2's toolchain is largely "obsolete"
Dropbox highlights that Python 2 has become increasingly incompatible with other tools they use for deploying software.
"As Python 2 has aged, the set of toolchains initially compatible for deploying it has largely become obsolete. Due to these factors, continued use of Python 2 was associated with a growing maintenance burden," it states.
For example, Dropbox says it had trouble working with the Qt application framework for building UIs on Windows and Linux, as recent versions of Qt require more modern compilers that were available for Python 2.
4. Python 2 doesn't work with some modern IDEs
Python 2 isn't compatible with some recent IDEs, for instance only supporting the aged Visual Studio 2008.
"At this point, continued use of Visual Studio 2008 was becoming highly costly," writes Dropbox.
The team needed an IDE that supported Python 2 and 3, so resorted to extensively altering their custom fork of Python 2 to make it properly compile using Visual Studio 2013.
"The cost of these changes further reinforced our belief that moving to Python 3 was the right decision," according to Dropbox.
5. It's difficult to use Python 2 with software development kits (SDKs) on Windows 10
Dropbox ran into further problems caused by Python 2 not being compatible with recent IDEs.
The fact Python 2 technically requires with Visual Studio 2008 was problematic, as this IDE isn't compatible with Windows 10 SDKs, hampering Dropbox's efforts to integrate its cloud storage service with the operating system.