The wait is over for those who constantly want to be updated with new features from their favorite programming language. As a Pythonista, I find myself drawn to a constant search for information about the language, searching for cool things and features. In this article, we shall discuss what's new and how to get started with Python 3.11.
I will assume that you are already a Python programmer or at least have used the language before; You could be a newbie which is still okay. I remember I joined the Python community almost two years ago and a time, If I remember the version was 3.7.6. So let's see these new features;
🌟 Python 3.11 New Features
The announcement came in yesterday and the release notes are available for everyone to read and utilize. Python 3.11 is between 10-60% faster than Python 3.10 according to the released notes.
The following are the main cool and new features of this new version of Python. I will personally get to write about each feature separately on its own if need be in different articles.
Python 3.11 is anywhere between 10-60% faster than Python 3.10, and on average it's 25% faster. This includes faster startup times and more efficient use of/communication with C. The proposal, which is known as the Shannon Plan, is very ambitious and hopes to make Python five times faster over several releases.
🔸Better Error Messages
Anyone who has used a language like Rust knows that Python left something to be desired when it came to error messages. Well, now Python has error messages that highlight the specific location of the problem!
We now have the introduction of the "except" clause, which allows you to have more flexible error handling. You can create a group of exceptions that may partially match with multiple of these except clauses.
🔸New Notes on exceptions
Sometimes, when you're catching an error, it's helpful to leave an extra note to the user as to exactly why the error was raised. Many libraries (like Keras) spend a lot of time trying to enhance this. Well, the .add_note() method now allows this!
🔸Improved Data & Type Hints
There's now support for a Self type and marking TypedDict items as required or not. But, the most exciting one for me is "variadic generics".
🔸Support for TOML Configuration Parsing
TOML is short for Tom’s Obvious Minimal Language. It’s a configuration file format that’s gotten popular over the last decade. The Python community has embraced TOML as the format of choice when specifying metadata for packages and projects.
Other notable features;
- Nicer Syntax for Asynchronous Tasks
- Improved libraries
The speed upgrade alone is exciting enough. But it's just the first stop on a longer roadmap to make Python faster (and maybe JIT compiled?). There's a master plan out there for Python 3.12 and beyond that has me extremely bullish on Python going forward. You too can contribute here;
🌟 So, Should You Upgrade to Python 3.11?
This finishes up your visit through the coolest enhancements and new elements in Python 3.11. A significant inquiry is whether you ought to move up to the new form of Python. Also, provided that this is true, when is the best time chance to upgrade?
Normally this depends because some and most python packages are still running the latest compatible versions which are usually the old versions of Python. The introduction of new features could deter the stability of some python frameworks; so your answer to this truly varies and depends on your use case but you can install python in a safe environment to try it out.
🌟 Installation & Updates
If you don't have Python yet on your machine; head over to this official website and download it to our machine; the steps are quite intuitive and straightforward.
To update the Python version, you have to download the latest Python installer. After that, run the installer and install Python's latest version. Then, verify the Python version using the “python -V” command.
Once again, hope you learned something today from my little closet.
Please consider subscribing or following me for related content, especially about Tech, Python & General Programming.
You can show extra love by buying me a coffee to support this free content and I am also open to partnerships, technical writing roles, collaborations, and Python-related training or roles.
📢 You can also follow me on Twitter: ♥ ♥ Waiting for you! 🙂