KEMBAR78
Subtype checking micro-optimization by JukkaL · Pull Request #19384 · python/mypy · GitHub
Skip to content

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Jul 6, 2025

Speeds up self-check by about 0.6%. The assertion is very hot, and the original version always created a set, which is slow.

Speeds up self-check by about 0.6%. The assertion is very hot, and
the original version always created a set, which is slow.
@JukkaL JukkaL requested a review from ilevkivskyi July 6, 2025 12:34
@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

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

@hauntsaninja hauntsaninja merged commit de23d08 into master Jul 6, 2025
19 checks passed
@hauntsaninja hauntsaninja deleted the mypyc-micro-opt-1 branch July 6, 2025 16:57
@sterliakov
Copy link
Collaborator

sterliakov commented Jul 7, 2025

There's an assert of exactly same form in is_proper_subtype, is it also worth rewriting?

@ilevkivskyi
Copy link
Member

@sterliakov Yes, that one should be rewritten as well (it is probably less hot, but still worth doing).

JukkaL added a commit that referenced this pull request Jul 16, 2025
…#19463)

This was suggested by @sterliakov in
#19384 (comment)

This is a part of a set of micro-optimizations that improve self check
performance by ~5.5%.
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.

5 participants