Loading video player…

Cool New Features in Python 3.11 (Overview)

Python 3.11 was published on October 24, 2022. This latest version of Python is faster and more user-friendly. After seventeen months of development, it’s now ready for production.

As in every version, Python 3.11 comes with lots of improvements and changes. You can see a list of all of them in the documentation. Here, you’ll explore the coolest and most impactful new features.

In this video course, you’ll learn about new features and improvements like:

  • Better error messages with more informative tracebacks
  • Faster code execution due to many efforts in the Faster CPython project
  • Task and Exception groups that simplify working with asynchronous code
  • Several new typing features improving Python’s static typing support
  • Native TOML support for working with configuration files

If you want to try any of the examples in this video course, you’ll need to use Python 3.11. Python 3 Installation & Setup Guide and How Can You Install a Pre-Release Version of Python? walk you through several options for adding a new version of Python to your system.

As you learn more about the new features coming to the language, you’ll also get some advice about which things you should consider before upgrading to the new version.

Download

Sample Code (.zip)

8.4 KB
Download

Course Slides (.pdf)

570.0 KB

00:00 Welcome to What’s New in Python 3.11. My name is Christopher, and I will be your guide to the improvements in the Python 3.11 release.

00:09 The course title says it all, but what’s that include? You’ll learning the 1.2x speed-up was achieved; new, more precise messaging in tracebacks; the addition of TOML to the standard library; and new features with exceptions and the new TaskGroup mechanism.

00:29 Python is on an annual release schedule, with releases usually coming early in October. The 3.11 release took a few weeks longer, but was worth waiting for.

00:39 A big chunk of the effort in this release is under the covers as part of the ongoing speed improvements to the CPython interpreter. They’ve achieved an average speed up of 1.2 times in each of the benchmark scripts versus the 3.10 performance, which itself had significant improvements.

00:57 The introduction of the PEG parser in Python 3.9 has allowed improvements in the error messages you see when something goes wrong. Python 3.11 continues along this path with more fine-grain information in the traceback output.

01:11 TOML is a popular configuration format in the Python world and is used by a lot of packaging tools. It has been promoted to a first-class citizen by being included in the standard library. There have also been some improvements to exceptions. First, you can now group exceptions together, and second, you can add clarifying notes to exceptions as well.

01:34 If you use the asyncio parallel computation module, you’ll find a new edition called the TaskGroup. This is a new way of invoking your async functions inside of a context manager, and it takes advantage of the new exception group mechanism when something goes wrong. There are also several new additions to type hint capabilities.

01:54 The Self type annotates the use of class within its methods, variadic types allow for the declaration of tuples of varying length, and a new decorator tells type systems that a class conforms to dataclass semantics. Next up, I’ll dive into all the speedy new things that Python does speedily.

Avatar image for Eric Chastain

Eric Chastain on Jan. 29, 2023

thanks .

Avatar image for BrendonBlaQ

BrendonBlaQ on May 13, 2023

thank you

Avatar image for A RaDerBerg Van Der Berg

A RaDerBerg Van Der Berg on May 4, 2024

I just got the link and I’m really excited to see the new updates! 😄

Avatar image for Christopher Trudeau

Christopher Trudeau RP Team on May 5, 2024

Hello RaDerBerg,

Glad to hear you’re excited. You’re also a version behind :)

Check out:

realpython.com/courses/new-features-python-312/

when you’re done with the new stuff in 3.11. Python just keeps growing and adding features.

Become a Member to join the conversation.