X Tutup
Skip to content

Mark triangulation classes as final#27894

Merged
dstansby merged 1 commit intomatplotlib:mainfrom
QuLogic:final-tri-classes
Mar 10, 2024
Merged

Mark triangulation classes as final#27894
dstansby merged 1 commit intomatplotlib:mainfrom
QuLogic:final-tri-classes

Conversation

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

X Tutup