Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Elastic Generics: Flexible Static Typing with TypeVarTuple and Unpack

PyCon US via YouTube

Overview

Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
This conference talk from PyCon US explores the powerful typing capabilities introduced in Python 3.11 through TypeVarTuple and Unpack. Discover how these features enable "elastic generics" - a flexible approach to static typing that combines both fixed ordering of component types and variable-length sequences. Learn how to progress from basic annotated tuple types to creating sophisticated variadic generic classes that can handle mixed fixed and unbound types with mypy validation. Explore a practical implementation through the creation of a generic Record class that can be parameterized in multiple flexible ways. The presentation culminates with a real-world application in the StaticFrame library, demonstrating how TypeVarTuple enables comprehensive generic typing for DataFrames - addressing the common scenario where datasets have fixed heterogeneously typed columns followed by variable numbers of uniformly typed columns. Perfect for Python developers looking to leverage advanced typing features for more expressive and type-safe code.

Syllabus

Elastic Generics: Flexible Static Typing with TypeVarTuple and Unpack

Taught by

PyCon US

Reviews

Start your review of Elastic Generics: Flexible Static Typing with TypeVarTuple and Unpack

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.