Should You Upgrade?
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 Class—A-B-C. An alias was kept for backward compatibility.
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
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: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.
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.
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.