Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

What's New in Python 3.12 (Summary)

Now you’re ready for the new release of Python! You’ve gotten a taste of the updates in Python 3.12, such as:

  • Improvements to f-strings
  • More did-you-mean error messages
  • New features in the standard library
  • Additions to static typing
  • Changes to the CPython interpreter

If you’d like to continue exploring, then be sure to read the Python documentation, What’s New in Python 3.12, as well as the PEPs that you’ve covered in this course:

Real Python also has you covered if you’d like to learn more about some of these improvements:

You can also check out the following links to dive deeper into topics covered in the course:


Sample Code (.zip)

8.1 KB

Course Slides (.pdf)

2.0 MB

00:00 In the previous lesson, I covered changes internal to CPython. In this last lesson, I’ll summarize the course and point you at sources of further investigation.

00:10 Python 3.12 has a variety of new features, including a change to how f-strings are parsed, resulting in the removal of some of their prior restrictions; improved error messages; the new batched() function in the itertools module to group things together; the new .walk() function in the pathlib module to recursively iterate through a directory tree; and two new enums in the calendar module, one for the months of the year and the other for the days of the week.

00:40 Two changes were made in the typing space. The @override decorator was added, giving this static checker the ability to signal if a method is supposed to override its parent but doesn’t, and there was new syntax added for generics that requires less code and no imports.

00:58 A bunch of internal CPython changes happened as well. Work continues on the GIL—in this release, moving it into the context of a subinterpreter, freeing extensions to become more parallel.

01:09 Immortal objects were introduced, reducing the memory cost of many immutable objects. The underlying code representing comprehensions has changed, improving their performance. And hooks were added to CPython, so you can take advantage of Linux’s perf profiler.

01:28 The Python docs have a post on what’s new in 3.12 if you want a complete list of what’s happening. You can also go diving through the PEPs. There’s a bunch.

01:38 Every PEP is available using this pattern of a URL, and you can replace the XXX with the PEP number to see it. This list of numbers is all of the PEPs I spoke about in the course.

01:49 Full links are available in the course notes. If you’d like to learn more about some of the Python concepts that were improved in 3.12, there are tutorials and courses that can help you out.

02:01 All the ones I’m going to point to you at are older than 3.12 though, so they won’t cover the new stuff I just went over, but they do have a lot of information on each topic if you need to learn some more.

02:11 This guide covers both the format() function and f-strings. If you’re not using f-strings yet, I suggest you move to them as soon as you can.

02:20 They’re are real improvement. To learn more about itertools—and there’s a whole bunch there—this article can help you out. If you’d like to learn about pathlib, you can see this resource. And to better understand type checking, this guide can be of use.

02:37 Several of these tutorials have courses as well. Links are provided in the course notes. That’s it for me. I hope you enjoy the new features of 3.12. Thanks for your attention.

Become a Member to join the conversation.