KEMBAR78
[mypyc] Optimize type(x) and x.__class__ by JukkaL · Pull Request #19691 · python/mypy · GitHub
Skip to content

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Aug 19, 2025

Using Py_TYPE avoids a function call. Also specialize x.__class__ for instances of native classes -- it's treated as equivalent to type(x). This is not generally possible, so only do it for native instances where we can make more assumptions.

Using `Py_TYPE` avoids a function call. Also specialize `x.__class__`
for instances of native classes -- it's treated as equivalent to
`type(x)`.  This is not generally possible, so only do it for native
instances where we can make more assumptions.
@JukkaL JukkaL merged commit 722f4dd into master Aug 19, 2025
13 checks passed
@JukkaL JukkaL deleted the mypyc-type branch August 19, 2025 15:33
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