Skip to main content Brad's PyNotes

Posts on Python 3.10

  1. PEP 604 Union Types

    TL;DR

    PEP 604 introduced the | operator for union types, allowing int | str instead of Union[int, str] for cleaner type annotations.

    Interesting!

    The | operator for union types makes Python’s type hints look more like mathematical set notation - int | str means “integer OR string”!

  2. PEP 622 Pattern Matching

    TL;DR

    PEP 622 introduced match-case statements for structural pattern matching, enabling elegant destructuring and dispatch based on data shape and values.

    Interesting!

    Pattern matching brings functional programming elegance to Python - you can destructure complex nested data in a single line and handle different cases cleanly!