Dynamic Pattern Matching with Python
summary
Claims a concrete design and prototype to add structural pattern matching to Python via a match statement with multiple case clauses, treating patterns as constructors and introducing a projection Pi to map rich objects to pattern slots. It defines a passive mapping (a tuple of attribute names) and an active mapping (a static match method that returns a tuple or failure, optionally parameterized with square brackets). Examples include an AST simplifier that collapses --x and drops *1 multiplications. A PEP encodes the core elements and a prototype targets Python 3.10.
AI-written summary · about
chapters (14)
- 0:00Intro
- 1:25Example: abstract syntax tree
- 2:04Example: filter and extract data
- 2:44Example: select a pattern and extract data
- 3:15Example: syntax of pattern matching
- 6:19Objects vs tagged tuples
- 7:04Patterns matching objects to patterns
- 8:39Explicit mapping
- 9:41Passive mapping
- 10:12Active mapping
- 12:06The objective of pattern matching
- 13:01Parametrise the mapping
- 14:13Parametrised patterns
- 14:33Summary
related talks
34mDynamic Pattern Matching with Python
26mStructural Pattern Matching in Python
26mThe Road to Pattern Matching in Python
10mAn Exploration of Python's Upcoming Match Statement
24mA Perfect Match The history, design, implementation, and future of Python's...
42mMatch Case for Beginners
46mSupercharge your code with Python's 'match' statement
30mAdvanced parsing of structured data using Python's new match statement
