Skip to content

Speed up bind_self() in edge cases involving protocols - #22319

Open
ilevkivskyi wants to merge 6 commits into
python:masterfrom
ilevkivskyi:faster-proto-impl
Open

ilevkivskyi wants to merge 6 commits into
python:masterfrom
ilevkivskyi:faster-proto-impl

Conversation

@ilevkivskyi

Copy link
Copy Markdown
Member

Fixes #20828

This has no effect on self-check, but improves edge cases involving self-types and protocols where currently performance is very bad. For example, altair should be ~2x faster. Two things here:

  • Use bind_self_fast() in situations where type_checker is not set (e.g. late stages of semantic analysis).
  • Add lightweight cache for cases where full bind_self() is required.

cc @JukkaL

@github-actions

Copy link
Copy Markdown
Contributor

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

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.

Runs forever at 100% CPU for generic protocol with bounded TypeVar argument

1 participant