Skip to content

Assorted niche optimizations #19587

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ilevkivskyi
Copy link
Member

These are few random micro-optimizations (plus few correctness fixes I noticed in the process):

  • De-serializing large callables/overloads is very slaw because of Enum.__call__()
  • Large unions without literals were forced through make_simplified_union() in code path that supposed to handle literals
  • Now that SomeType.__eq__() is called more often and we preserve more original types in expand_type() I added couple fast paths after gathering call stats there.

In total this gives ~0.5% on self-check, but makes loading some numeric libraries from cache up to 10% faster.

Copy link
Contributor

github-actions bot commented Aug 4, 2025

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@A5rocks
Copy link
Collaborator

A5rocks commented Aug 4, 2025

Could mypyc maybe do an optimized version of the Enum thing? Surely there's other marginal uses of this pattern too...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants