Skip to content

TYP: Simplified dtype.__new__ overloads #29168

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

Merged
merged 1 commit into from
Jun 11, 2025

Conversation

jorenham
Copy link
Member

This reduces the number of overloads from 65 to 40. Overloads are very computationally expensive to typecheck, because all combinations of overloads have to be considered. I haven't tested it myself, but I wouldn't be surprised if this change reduces the average runtimes of the mypy's and the pyright's by a couple of seconds.

Most of the "removed" overloads were merged into another the same return type. Some others for abstract scalar-types like flexible and generic were also removed, because I doubt that they will ever be used in realistic use-cases. And I figured that the primer will tell us if that assumption is false.

@charris charris merged commit 7bb70e1 into numpy:main Jun 11, 2025
77 checks passed
@charris
Copy link
Member

charris commented Jun 11, 2025

Thanks Joren.

@jorenham jorenham deleted the typing/simplified-dtype-constructor branch June 11, 2025 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants