Typing in Python: Bringing Clarity, Safety, and Speed to Your Code
summary
Adds static type annotations like list[str] → dict[str, list[str]], generics via TypeVar T for functions that return the same element type as their list input, type aliases such as Vector = list[float], and NewType wrappers for domain IDs. Annotations do not change runtime behavior but allow static checkers (mypy recommended) to find mismatches like passing a string where an int is expected before deployment, improving code quality and reducing runtime type errors in large codebases.
AI-written summary · about
chapters (10)
- 0:00Introduction to Python typing
- 1:48Why types improve code quality
- 3:35Static analysis with type hints
- 6:24Basic type annotations
- 7:50Complex data structures
- 8:54Generics and aliases
- 11:47Custom types
- 12:51Union types
- 13:54Next steps with static tools
- 15:21Summary and Q&A
related talks
32mType-checked Python in the real world
35mStatic Typing in Python
32mStatic Typing in Python
29mPython Type hints and how they can supercharge CS education.
12mType Annotations in Python: Terribly Intimidating or Tremendously Informative?
29mStatic Typing in Python
22mStatic Typing in Python
29mGetting Started with Statically Typed Programming in Python 3.10
