Advanced parsing of structured data using Python's new match statement
summary
Demonstrates using Python 3.10+ pattern matching to parse real data and to transform code by scanning ASTs with inspect and ast, building an automatic refactor that turns isinstance if‑chains into match nodes and it works on functions with a single match variable. Benchmarks show match is about 2× slower than equivalent if checks except a surprising win on a list-of-integers case, and an inline capture form is markedly slower than explicit capture. Examples include parsing JSON, XML (ElementTree/element-style objects) and ASTs.
AI-written summary · about
chapters (7)
- 0:00Introduction to match
- 1:43Advanced pattern matching
- 4:34Adoption and documentation
- 6:27Parsing applications
- 25:14Benchmarking performance
- 26:50Conclusion and resources
- 28:01Q&A session
related talks
10mAn Exploration of Python's Upcoming Match Statement
26mStructural Pattern Matching in Python
24mA Perfect Match The history, design, implementation, and future of Python's...
34mDynamic Pattern Matching with Python
18mmeet the best feature in python 3.10: match-case
42mMatch Case for Beginners
16mDynamic Pattern Matching with Python
26mThe Road to Pattern Matching in Python
