Skip to content
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

chore: use explicit defaulting in pyobject macros #4017

Conversation

Skylion007
Copy link
Collaborator

@Skylion007 Skylion007 commented Jun 18, 2022

Description

  • This change makes the pyobject macro uses the equals-default instead of defining an empty ctor. The behavior should be identical to before, but the ctor is now trivial, enabling more compiler optimizations.

Suggested changelog entry:

* Explicitly default all relevant ctors for pytypes in the PYBIND11_OBJECT macros and enforce the clang-tidy checks modernize-use-equals-default in macros as well.

@Skylion007 Skylion007 requested review from rwgk and henryiii June 18, 2022 22:39
…skylion007/pyobject-default-macro-use-default
@Skylion007
Copy link
Collaborator Author

Sigh, this is now only a bug with the NVIDIA compilers.

@rwgk
Copy link
Collaborator

rwgk commented Jul 19, 2022

Sigh, this is now only a bug with the NVIDIA compilers.

I'm a bit confused TBH, IIRC there were more failures before, but I cannot figure out what changed.

Before and now, I was/am only seeing this trivial issue:

"/__w/pybind11/pybind11/include/pybind11/numpy.h", line 540: error: extra ";" ignored
      PYBIND11_OBJECT_DEFAULT(dtype, object, detail::npy_api::get().PyArrayDescr_Check_);

In theory this PR could break user projects with extra ";" & -Werror, but Google-internally I just did a (very quick) global code search for PYBIND11_OBJECT_DEFAULT and PYBIND11_OBJECT_CVT_DEFAULT: the only matches are in the pybind11 sources.

Therefore I believe this PR is safe, we just need to remove the extra ";" and add a small warning in the changelog.

@Skylion007 Skylion007 merged commit 42b5450 into pybind:master Jul 20, 2022
@Skylion007 Skylion007 deleted the skylion007/pyobject-default-macro-use-default branch July 20, 2022 16:02
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Jul 20, 2022
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Oct 20, 2022
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.

3 participants