On October 5, 2020, Python released a new version of Python, 3.9.0rc2. In this article, I will introduce you to the updates to Python in Python 3.9. Here you will get all the important information about the highlights of the release, new features, new modules, optimization and some code samples to try it out in your environment.
Python 3.9 Basic Updates
So the new updates are mostly concerned with how we can merge two dictionaries in Python. So let’s have a look:
Also, Read – Machine Learning Full Course for free.
a = {‘first’: 1, 'second’: 2, 'python’: 3}
b = {’first’: 'third’, 'forth’: 'python3.9’}
a | b
Code language: Python (python)
{’second’: 2, 'python’: 3, ’first’:’third’, 'forth’: 'python3.9’}
Now we don’t need an external library to update the time zone. Now the zoneinfo module has been added to the standard library. It supports the IANA time zone database, as follows:
from datatime import datetime
#from pytz import timezone <<<<<<<<<< #No need it!!!
from zoneinfo import ZoneInfo
current_t=datetime.now()
current_t_paris= datetime.now()
print(current_t.astimezone(ZonInfo('Europe/Paris')))
Code language: Python (python)
2020-10-06 05:04:01.932145+06:00
And some major updates regarding prefix and suffix can also be seen in the new version of Python:
professors = ['Prof. A', 'Prof. B', 'Prof. C']
names_only=[]
for professor in professors:
names_only.append(professor.removeprefix('Prof. ')
print(names_only)
Code language: PHP (php)
['A', 'B', 'C']
Python 3.9 Other Updates:
The new version brings a new PEG-based parser to CPython replacing the previous LL-based parser (LL (1)), multi-processing enhancements, quick access to module state from extension type methods C, and a number of other performer improvements.
PEG analyzers are more powerful than LL (1) analyzers and avoid the need for special hacks. The PEG parser was implemented in the new version. Typically, the PEG parser produces the Abstract Syntax Tree (AST) like the old LL parser (1).
To sum up, the PEG analyzer is slightly faster, but it also uses a little more memory. In practice, you should not notice any change in performance when using this new analyzer.
Should You Upgrade to Python 3.9?
If you want to try out any of the cool new features, you’ll need to use Python 3.9. So you can upgrade and then go back to your current version of Python. You should keep in mind that if you have code running in Python 3.8 without any issues, you may experience issues when running the same code in Python 3.9.
Also, the new PEG analyzer has naturally not been tested as extensively as the old one and only time will tell the truth about it. As always, if you are unsure of this version and want to be more conservative, you can wait for the first maintenance release: Python 3.9.1.
Will I Upgrade to New Version?
This new version of Python seems to have some very interesting features. Still, it’s not a revolutionary version but it could lead to better user experience. This release is a milestone for the Python community.
Hopefully, in a few years, Python 3.9 will be as widespread as Python 3.6 is now because it’s always nice to see how Python evolves with new features and parsers. I don’t think I need to upgrade my version 3.6 of Python to Python 3.9. As a being in Machine Learning, Python 3.6 is the most suitable version.
Hope you liked this article on the new upgrades of Python programming language. You can download the new version from here. Please feel free to ask your valuable questions in the comments section below.