Python 3.10 with structural pattern matching has appeared

Spread the love

The Python release team has released version 3.10.0 of the programming language. Python 3.10.0 includes support for precise line numbering, which can benefit debugging tools, and structural pattern matching.

The Python Software Foundation lists the main Python Enhancement Proposals or PEPs for Python 3.10.0. It contains, among other things, the PEPs for preparing for the removal of the wstr member in PyUnicodeObject and allowing writing union types such as X | Y at.

In addition, PEP brings 626 precise line numbers for debugging and other tools to the 3.10 series. The release team describes that Python should guarantee that line tracing events should be generated for all executed lines of code and also only for executed lines of code if tracing is enabled. Version 3.10 adds a co_lines attribute for debugging tools. It describes the mapping from bytecode to source.

Structural pattern matching involves matching a pattern with a subject value. That match may be successful or not. The technique is suitable for taking apart data structures and thus making it possible to write cleaner, more readable code. Syntax for pattern matching is already in the programming languages ​​Haskell, Erlang and Ruby, and there is a proposal for support for JavaScript. Python support has been limited so far, and the functionality in 3.10 builds on the limited support that was already there. The specification of and underlying motivation for structural pattern matching are further described in PEP 634, 635 and 636. The most important changes are those for better error messages and parenthesized context managers.

.fb-background-color { background: #ffffff !important; } .fb_iframe_widget_fluid_desktop iframe { width: 100% !important; }