Structural Pattern Matching

E253899

Structural Pattern Matching is a Python language feature, introduced via PEP 622, that enables powerful, declarative matching of complex data structures using a `match`/`case` syntax.

All labels observed (4)

How this entity was disambiguated

Statements (50)

Predicate Object
instanceOf Python language feature
availableFromVersion 3.10
belongsTo Python language core
canMatch dictionaries
enums
lists
literals
tuples
user-defined classes
definedIn PEP 634
enables concise handling of variant data types
data-driven control flow
more readable branching logic
evaluates patterns top to bottom
fallsThrough no
hasMotivationIn PEP 635
hasSemanticsSpecifiedIn PEP 634
hasSyntaxKeyword case
match
hasTutorialIn PEP 636
inspiredBy pattern matching in Haskell
pattern matching in Rust
pattern matching in Scala
pattern matching in functional languages
introducedBy PEP 622
introducedIn Python 3.10
is a structural rather than nominal matching system
isAlsoKnownAs Python pattern matching
match-case syntax
notAvailableBeforeVersion 3.10
requires subject expression after match keyword
selects first matching case
supports AS patterns
OR patterns
capture patterns
class patterns
declarative pattern matching
destructuring of values
keyword subpatterns
literal patterns
mapping patterns
matching of complex data structures
pattern guards
positional subpatterns
sequence patterns
value patterns
wildcard patterns
uses case clauses for patterns
usesKeyword case _ as wildcard pattern
if for pattern guards

How these facts were elicited

Referenced by (4)

Full triples — surface form annotated when it differs from this entity's canonical label.

PEP 622 hasTitle Structural Pattern Matching
PEP 634 title Structural Pattern Matching
this entity surface form: Structural Pattern Matching: Specification
PEP 635 title Structural Pattern Matching
this entity surface form: Structural Pattern Matching: Motivation and Rationale
PEP 636 title Structural Pattern Matching
this entity surface form: Structural Pattern Matching: Tutorial