During the Python Language Summit 2026, Michael J. Sullivan introduced PEP 827, a proposal aimed at introducing powerful type manipulation capabilities inspired by dynamic type behaviors seen in other languages like TypeScript.
Type Manipulation Primitives
PEP 827 introduces several foundational primitives to Python's type system, including conditional types, comprehension types featuring optional filtering, and member types that expose an iterable of a type's members alongside properties for member names and types. According to the discussion, the proposal avoids adding new keywords and includes a mypy-based prototype for the suggested features.
A primary use-case involves streamlining CRUD web applications where database models require multiple variations for different database operations. Rather than manually maintaining redundant model definitions, developers could leverage transformations like public views, creation models, and update variations directly from a base model.
Runtime Annotation Storage Trade-Offs
A major focus of the proposal is determining how type annotations should be stored and evaluated at runtime, given that modern libraries like Pydantic and FastAPI rely heavily on runtime type information. The draft relies on an evaluator utilizing __annotate__() functions, exploring options such as utilizing annotationlib's string format or combining string representations with environment closures for evaluation via eval().
During core developer discussions, participants debated the memory and computation trade-offs of storing raw strings versus evaluating closures. Łukasz Langa suggested that interning common annotation strings within __annotate__() could save memory without significantly impacting performance.
Intentional Turing-Completeness and Syntax Concerns
Addressing concerns regarding type system complexity, Sullivan noted that accepting the proposal would transition Python's type system from being accidentally Turing-complete to intentionally Turing-complete, comparing it to similar generic behaviors in Java. Core developers also discussed the aesthetic impact of complex derived types on everyday developers.
Łukasz Langa and David Hewitt raised concerns about whether complex syntax could overwhelm users inspecting API return types, similar to experiences in TypeScript ecosystems. Co-author Yury Selivanov acknowledged that while advanced type transformations introduce complexity, they are necessary to match Python's runtime expressiveness, supported by improvements in IDEs and language servers.
AI-generated editorial illustration; not a documentary photograph.
Source: PEP 827: Type Manipulation (Python Language Summit 2026)

Leave a Reply