Skip to content

[mypyc] Document some of our inheritance conventions #19370

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

Merged
merged 2 commits into from
Jul 3, 2025

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Jul 2, 2025

Our policy wasn't clear from just reading the code.

Our policy wasn't clear from just reading the code.
Comment on lines +22 to +23
This makes it possible to use isinstance(x, <concrete Value
subclass>) checks without worrying about potential subclasses.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be a good idea to mark the concrete classes as @final to document/enforce this?

On a somewhat related noted, can/does mypyc optimize isinstance checks with final types?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that, added @final to the concrete classes. By default @final doesn't help with optimizations, since mypyc can perform whole-program analysis. However, @final would help with isinstance checks if doing separate compilation (but this is currently poorly supported).

@brianschubert brianschubert added the topic-mypyc mypyc bugs label Jul 2, 2025
@JukkaL JukkaL merged commit 1bf186c into master Jul 3, 2025
13 checks passed
@JukkaL JukkaL deleted the mypyc-doc-inheritance branch July 3, 2025 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-mypyc mypyc bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants