Locked learning resources

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

Unlock This Lesson

Locked learning resources

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

Unlock This Lesson

Cool New Features in Python 3.10 (Summary)

The release of a new Python version is always worth celebrating. Even if you can’t start using the new features right away, they’ll become broadly available and part of your daily life within a few years.

In this course, you’ve seen new features like:

  • Friendlier error messages
  • Powerful structural pattern matching
  • Type hint improvements
  • Safer combination of sequences
  • New statistics functions

Sample Code (.zip)

38.6 KB

Course Slides (.pdf)

5.3 MB

00:00 In the previous lesson, I covered the smaller improvements to Python 3.10. In this lesson, I’ll briefly highlight whether you should upgrade, then give a summary of the course. Upgrading the interpreter is necessary if you want to play around with any of Python 3.10’s new features.

00:16 You might also want to upgrade just to take advantage of bug fixes and other things that always come with an upgrade.

00:22 The flip side of this is that some of your favorite packages may not have wheels ready yet, but that will come in time. There has been lots of beta testing, but that doesn’t mean this release is perfect—it is still software, after all. If you’re thinking of upgrading production servers, I would highly suggest you run a lot of tests first.

00:39 You do have automated tests, don’t you? You can also consider one of several ways of having multiple interpreters installed at a time. On my own system, I have everything from Python 3.6 through 3.10 installed, and then use virtual environments per project.

00:54 You can also use pyenv, conda, or Docker containers to manage your system as well. The more important question in my mind is whether to start using the new language features. This comes down to: “Well, it depends.” If you’re in full control of your environment and writing code for yourself, then of course, take advantage of it. On the other hand, if you’re a library maintainer, you might not want to embrace the new features yet.

01:18 Not if you want your library to be backwardly compatible. I still haven’t used the walrus operator from 3.8 for exactly this reason. On the topic of older versions, don’t forget that Python 3.6 reaches end-of-life in December 2021.

01:32 One less interpreter to support if you’re writing library code.

01:37 This course was all about the new features in Python 3.10. It covered the new pattern matching syntax using the match and case keywords, improved error messages, more type hinting features, and general annotation tools.

01:53 I also covered asynchronous iteration with aiter() and anext() and the three new functions in the statistics library: correlation(), covariance(), and linear_regression().

02:05 Also covered were the new strict argument to the zip() function, the -X warn_default_encoding command-line flag, the use of parentheses to support multiple context managers in a with block, the upgraded requirements of the OpenSSL underlying library, and finally, the two new values available in the sys module: stdlib_module_names and orig_argv.

02:33 That’s all for Python 3.10! Thanks for your attention, I hope you enjoyed the course.

Avatar image for Jon David

Jon David on Oct. 7, 2021

Thanks for this!

Avatar image for jason84

jason84 on July 17, 2022

Interesting and useful.

Avatar image for Christopher Trudeau

Christopher Trudeau RP Team on July 18, 2022

Glad you found it helpful Jason. I’ve been using it a lot lately and the error messages can’t be beat. They make a big difference in the day-to-day experience.

Happy coding!

Become a Member to join the conversation.