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

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Should You Upgrade?

00:00 In the previous lesson, I talked about a couple of changes to the math library and HTTPStatus. In this lesson, I’m going to be talking about when or how soon you should upgrade to Python 3.9.

00:12 As part of the ongoing transition from Python 2 to 3, features have been deprecated along the way in Python 3, and some of those are slowly being removed. For example, collections.Mapping was moved to collections.abc.Mapping to indicate it was an Abstract Base ClassA-B-C. An alias was kept for backward compatibility.

00:34 That’s been deprecated, and eventually will be removed. To check whether or not your application triggers any of these deprecations, you can use the -W flag with a value of either default or error when you run Python on the command line.

00:48 It’ll report to you with a warning or fail to run with an error if you have one of these problems. Even more removals are coming in Python 3.10. Slowly, the vestige of Python 2 is withering away.

01:03 Another change that’s happening with Python 3.9 is the release cycle. This is a process change rather than a code change. Python originally was released about every 18 months.

01:13 They have decided to move to a 12-month release cycle. Releases will be aimed to be in October every year. Like now, each version will continue to be supported for 5 years after its release date. This change in pace means new features will come faster, but there’ll be fewer of them for each release.

01:32 The development of a release starts about 17 months before the release date, and there’s a feature freeze in the 5 months prior to the release for the testing phase. As an example, Python 3.9 is being released in October of 2020, but Python 3.10 is well underway.

01:52 A small word of caution. Python 3.10 will be the first release with a double-digit minor version. The reason this might be a problem is because you have to be careful how you compare versions.

02:03 There’s some code out there that has used greater than (>) on the string comparison in order to compare Python versions. Unfortunately, "3.9" is greater than "3.10".

02:14 Instead, you should be using tuples. The (3, 9) tuple is not greater than the (3, 10) tuple, so this is behaving the way you need. To help you catch this, the flake8-2020 library looks for this kind of problem, and others.

02:29 This brings me to the question, “Should you upgrade?” Well, the answer is “Of course.” The real question is “When?” and it’s not going to be a static answer—it’s going to depend on your own needs.

02:40 If you want to play with the new features right now, knock yourself out. The best way to do that is with a side-by-side install, having multiple versions of Python on your machine.

02:50 You can then manage those with environment managers or a Docker image.

02:54 If you’re running Python 3.8 in production, the transition should be fairly smooth.

03:00 The only problems will be if you’re currently using deprecated code that got removed in 3.9, or if you’re really unlucky and hit an edge case with the PEG parser.

03:09 Make sure you run your tests. You have tests, don’t you? A related question isn’t just about updating the interpreter, but also, “When do you use the new features that aren’t backwardly compatible?” Again, that depends on you. If your project is fully under your control, then knock yourself out. If, on the other hand, you’re writing a project or—particularly—libraries that are used by other people who may not be using Python 3.9, you might want to continue being backwardly compatible to Python 3.6.

03:40 This means you might want to wait a little longer before you use these new features. For a full list of all of the changes, you can visit the What’s New document for the Python 3.9 interpreter. In particular, the Porting to Python 3.9 section has details about challenges you might have in trying to convert from previous versions. In the next lesson, I’ll give you a brief summary of the content that’s been covered in this course.

Become a Member to join the conversation.