Skip to content

Look for performance improvements related to large unions #4781

@erictraut

Description

@erictraut

The pydantic source base includes a type alias called CoreSchema that is defined as a union with 40+ types. This type alias is used in many parts of the code, including TypeVar bounds. When I run pyright on the pydantic code base, it takes more than 20s to complete. If I reduce the number of items in the CoreSchema union from 40 to 5, the total type checking time drops to less than 1s. We should determine if there are ways to avoid n^2 (or worse) behaviors for common operations on unions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions