Python 2 retired in January 2020
Python 2 (python 2.7.2) was released in the year 2011. Python 2.7 was the last updated version of its 2.x series. Python 2.x series is moving into an extended maintenance period. It is also said that it’s going to be the “sun setting period” of python 2.0. Python 2.0 is no longer under development.
Let’s look into the basic key advantages between Python 2 and Python 3 –
- Python 3 was released in the year 2008 whereas Python 2 was released in the year 2000.
- Syntaxes used in Python 3 are comparatively easier than Python 2.
- Many developers are using updated libraries for Python 3. Many of these libraries are not compatible with Python 2.
How Python 3 is better than Python 2
- Python 3 supports more libraries that as compared to Python 2. This is the one of the key reasons behind why Python 2 is being phased out.
- Print statement has been replaced by print() function.
- iterkeys(), dict.iteritems() and dict.itervalues() are no longer supported in Python 3.
- Zip() returns an iterator.
- Range() function behaves like xrange() used to work.
- Long has been renamed to int. So there is only one built in data type, int. So no longer need to remember all different datatypes.
- Python 3 uses the concept of text and binary data instead of Unicode strings and b-bit strings. All texts are Unicode, however encoded Unicode is represented as binary value. The type used to hold text is str, the type used to hold data is bytes. One of the big differences between Python 3.x and 2.x is the elimination of errors whenever user mixes two different of data types. A TypeError is raised in Python 3 if the user mixes data types. Furthermore, in python 2.x it would work if the 8-bit string happened to contain only 7 bits ASCII byes, in Python 3.x programmers will get a UnicodeDecodeError. This has raised confusion among many people.
Why Migrate to Python 3
The core development community of python is urging users to migrate to Python 3.x. Python 2.x series will not be updated for bugs and security vulnerabilities anymore. The last major version of python 2.7 will be released by April 2020. Users who upgrade to Python 3.x will also benefit from security features in the new release.
The final security release was planned for the year 2015, however it has come a long way after that. It delayed 5 years to give people adequate time to upgrade to Python 3.
Python 3 has some noticeable improvements from the previous series. Some of them are as follows: 1) ground-up support for Unicode and internationalization, 2) better idioms and patterns, which makes the code more readable and easily understandable, and 3) improvements in concurrency, fault handling, testing, and debugging provides the developer with the opportunity to create more robust and secure applications.
In order to make big changes to python, the core developers of python decided to cease the development of Python 2.x as it was impeding the development of improvements. As of January 1, 2020 no bug fixes will be made to Python 2. However if the programmer has written code in Python 2, he can easily port it to Python 3.
If someone is dependent on the softwares written in Python 2, they can easily upgrade their tools. Indeed, according to core python developers, Python 3 is way more efficient and easier to use.