|
|
Subscribe / Log in / New account

Hoyt: Structural pattern matching in Python 3.10

Hoyt: Structural pattern matching in Python 3.10

[Development] Posted Sep 20, 2021 22:40 UTC (Mon) by corbet

Ben Hoyt has published a critical overview of the Python 3.10 pattern-matching feature.

As shown above, there are cases where match really shines. But they are few and far between, mostly when handling syntax trees and writing parsers. A lot of code does have if ... elif chains, but these are often either plain switch-on-value, where elif works almost as well, or the conditions they’re testing are a more complex combination of tests that don’t fit into case patterns (unless you use awkward case _ if cond clauses, but that’s strictly worse than elif).

(Pattern matching has been covered here as well).

Comments (9 posted)


Copyright © 2021, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds