Programma
Login

Structural Pattern Matching in the Real World

Abstract

This talk walks you through several real world examples of structural pattern matching. You’ll learn the common use cases, the problems you’re likely to encounter, and how to solve them.

  • Formatting mini language for date time objects
  • Marshal style data serialization
  • A language tokenizer
  • Query data in a JSON Lines format
  • Query multilevel JSON schemas
  • Recursive parsing for arbitrary JSON trees
  • Query lists of dataclass or named tuple objects

Also, we’ll look at practical solutions common problems:

  • Matching variables or expressions.
  • Ordering cases to avoid false positives
  • Ordering cases for performance
  • Matching a set or frozenset
  • How to invert tests
  • How to match exact type matches
  • How to match regular expressions
  • Preventing bugs with a catchall default
  • When to abandon match/case in favor of if/elif
  • Mental model for debugging match/case

Slides available here

Speaker
Raymond Hettinger
Lingua
Inglese
Speaker name:
Raymond Hettinger
Torna al programma
      Powered by Vercel Logo