Skip to content

Subtype checking micro-optimization#19384

Merged
hauntsaninja merged 1 commit into
masterfrom
mypyc-micro-opt-1
Jul 6, 2025
Merged

Subtype checking micro-optimization#19384
hauntsaninja merged 1 commit into
masterfrom
mypyc-micro-opt-1

Conversation

@JukkaL

@JukkaL JukkaL commented Jul 6, 2025

Copy link
Copy Markdown
Collaborator

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

github-actions Bot commented Jul 6, 2025

Copy link
Copy Markdown
Contributor

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

sterliakov commented Jul 7, 2025

Copy link
Copy Markdown
Collaborator

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

@ilevkivskyi

Copy link
Copy Markdown
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