Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look for performance improvements related to large unions #4781

Closed
erictraut opened this issue Mar 15, 2023 · 1 comment
Closed

Look for performance improvements related to large unions #4781

erictraut opened this issue Mar 15, 2023 · 1 comment
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request

Comments

@erictraut
Copy link
Collaborator

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.

@erictraut erictraut added enhancement request New feature or request addressed in next version Issue is fixed and will appear in next published version labels Mar 15, 2023
erictraut pushed a commit that referenced this issue Mar 16, 2023
…y of unions with many subtypes. This further reduces the analysis time of pydantic from 12s to 4s. This addresses #4781.
@erictraut
Copy link
Collaborator Author

This is included in pyright 1.1.300, which I just published. It will also be included in a future release of pylance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant