Skip to content

Mark triangulation classes as final #27894

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 1 commit into from
Mar 10, 2024

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Mar 9, 2024

PR summary

Prior to their conversion to pybind11 classes in #24522, these types had tp_flags = Py_TPFLAGS_DEFAULT, meaning they did not have the Py_TPFLAGS_BASETYPE flag and could not be subtyped. As these are internal classes, I don't believe this was intentionally changed, so restore that flag.

Additionally, since we require C++17 now, mark the C++ classes themselves as final. I believe this really only makes a difference if we have virtual methods (which we don't here), but that doesn't mean the compiler can't infer some other optimizations with this information.

PR checklist

Prior to their conversion to pybind11 classes in matplotlib#24522, these types
had `tp_flags = Py_TPFLAGS_DEFAULT`, meaning they did not have the
`Py_TPFLAGS_BASETYPE` flag and could not be subtyped. As these are
internal classes, I don't believe this was intentionally changed, so
restore that flag.

Additionally, since we require C++17 now, mark the C++ classes
themselves as `final`. I believe this really only makes a difference if
we have `virtual` methods (which we don't here), but that doesn't mean
the compiler can't infer some other optimizations with this information.
@dstansby dstansby added this to the v3.9.0 milestone Mar 10, 2024
@dstansby dstansby merged commit 816f036 into matplotlib:main Mar 10, 2024
@ianthomas23
Copy link
Member

I am not in favour of these changes. None of the C++ classes here are polymorphic, there are no virtual functions, there are no vtables, all function calls are direct function calls and there are no optimisations available. It looks like unnecessary code churn and an increase in code complexity for no tangible benefit.

@QuLogic QuLogic deleted the final-tri-classes branch September 20, 2024 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants