← Back to blog

Python 3.10.0 Release 🐍

October 4, 2021  ·  3 mins  ·  Python

Today, the final version of CPython 3.10.0 has been released. New, long awaited and controversial features enter the Python programming language.

We have just celebrated the 30th birthday of CPython, which was released on February 20, 1991, in version 0.9.01. Now a new event is coming up. The release of Python 3.10.0.

Some new and interesting features, like the replacement of typing.Union with the overload operator | and Explicit Type Aliases are introduced into the programming language. And then there is Structural Pattern Matching.

Structural Pattern Matching

Even before that, controversial features, such as PEP 484 – Type Hints , were added to Python. Some programmers are still not happy Type Hints. A part of them come to terms with it, others, including myself, appreciate the feature. But now a new feature comes along. Structural Pattern Matching – a “not that pythonic” version of if/else, Guido never wanted to add to the Python programming language, or like C programmers would call it: “The Python version of the switch/case statement”.

Example

def http_error(status):
  match status:
    case 400:
      return "Bad request"
    case 404:
      return "Not found"
    case 418:
      return "I'm a teapot"

However, leaving aside The Zen of Python2 the feature could still be useful. Unfortunately, I have a hard time with that. The words of Tim Peters are more than a few tips and rules for me. I associate with them more an attitude to life (and some well-thought-out programming rules).

It remains to be seen whether the feature will catch on. I assume that it will behave like Type Hints and it will first take a while until it catches on. However, for developers who have not been programming for quite so long, this should be much faster.

Release highlights3

New syntax features:

  • PEP 634 – Structural Pattern Matching: Specification
  • PEP 635 – Structural Pattern Matching: Motivation and Rationale
  • PEP 636 – Structural Pattern Matching: Tutorial
  • bpo-12782 – Parenthesized context managers are now officially allowed.

New features in the standard library:

  • PEP 618 – Add Optional Length-Checking To zip.

Interpreter improvements:

  • PEP 626 – Precise line numbers for debugging and other tools.

New typing features:

  • PEP 604 – Allow writing union types as X | Y
  • PEP 613 – Explicit Type Aliases
  • PEP 612 – Parameter Specification Variables

Important deprecations, removals or restrictions:

  • PEP 644 – Require OpenSSL 1.1.1 or newer
  • PEP 632 – Deprecate distutils module.
  • PEP 623 – Deprecate and prepare for the removal of the wstr member in PyUnicodeObject.
  • PEP 624 – Remove Py_UNICODE encoder APIs
  • PEP 597 – Add optional EncodingWarning

A full list can be found in the Python documentation: What’s New In Python 3.10

This blog post was updated on November 18, 2024

Categories
Tags
PythonPython and Release
Newer
Spaces Announcement πŸŽ‰
Top