Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News TensorFlow 2.1.0 Will Be the Last Version to Support Python 2

TensorFlow 2.1.0 Will Be the Last Version to Support Python 2

The TensorFlow project announced a release candidate for version 2.1.0. In addition to several improvements and bug fixes, this release will be the last version of the deep-learning framework to support Python 2.

The project team announced the release and the end of support for Python 2 on Twitter. The release also contains several new features. Performance improvements include default support for GPU in the tensorflow pip package and support for TensorRT 6.0. TensorRT is NVIDIA's "high-performance inference optimizer and runtime" that performs machine-learning inference using lower-precision arithmetic. This can improve TensorFlow's performance up to 8x with the addition of only a few lines of code. TensorFlow's Keras integration includes improved support for cloud-based tensor-processing units (TPUs) and a new TextVectorization layer which simplifies pre-processing for natural-language processing (NLP) tasks. The release does have a known issue that "Windows binaries are expected to be slightly slower until the build issues are resolved."

The TensorFlow team announced the upcoming end of support for Python 2 earlier this year. TensorFlow is following many open-source Python projects that have made the switch, including machine learning project scikit-learn, which ended support for Python 2 with the release of version 0.21 earlier this year. Python 3 has been available since 2008, and the end-of-life (EOL) for Python 2 was initially slated for 2015, but many developers have postponed the switchover for various reasons. Earlier this year, the Python Software Foundation finally announced that EOL for Python 2 will be January, 2020. 

The growth of machine learning software development is recent enough, relative to the lifecycle of Python 2, to prompt a Reddit user to wonder, two years ago, why Python 3 was not the default choice instead of Python 2. Responders speculated that Google's internal use of Python 2.7 was one reason, as was Apple's choice of 2.7 as the default installation on MacOS; others pointed out that Python 2 was by far more popular and few developers saw the benefit of using Python 3. Replying to the thread, Olivier Grisel, a contributor to scikit-learn, urged readers:

please, please, please, write new code in Python 3 first, only add Python 2 [compatibility] when you deal with a legacy code-base and stop advertising Python 2 as the default recommended platform. Python 2 is legacy and it's costly. It should be treated as such.

For deep-learning frameworks in particular, the two most popular choices---TensorFlow and PyTorch---both were released after the original 2015 EOL of Python 2. Indeed, the second issue ticket raised for PyTorch was a proposal not to support Python 2 at all. The issue was closed almost immediately, with commenters citing the order-or-magnitude larger popularity of Python 2 over Python 3. A similar ticket was opened earlier this year with several supporting comments. However, PyTorch creator Soumith Chintala stated that the project's official position was to:

Continue to support Python 2 for some indefinite period of time after 2020 EOL, until we see that Python 2 usage has dropped sufficiently for us to drop it

The TensorFlow code and version 2.1.0 release notes are available on GitHub.

Rate this Article