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

Trivial refactoring to make the capsule API more user friendly. #4720

Merged
merged 2 commits into from
Jun 27, 2023

Conversation

rwgk
Copy link
Collaborator

@rwgk rwgk commented Jun 27, 2023

Description

Enable

return py::capsule(ptr, "name", dtor);

vs

py::capsule cap(ptr, dtor);
cap.set_name("name");
return cap;

Suggested changelog entry:

The ``capsule`` API gained a user-friendly constructor (``py::capsule(ptr, "name", dtor)``).

@rwgk rwgk marked this pull request as ready for review June 27, 2023 19:31
@rwgk rwgk requested a review from EthanSteinberg June 27, 2023 19:31
Copy link
Collaborator

@EthanSteinberg EthanSteinberg left a comment

Choose a reason for hiding this comment

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

This looks perfect. Can you also update https://github.com/pybind/pybind11/blob/master/include/pybind11/pybind11.h#L512 to switch to the new API?

@rwgk
Copy link
Collaborator Author

rwgk commented Jun 27, 2023

This looks perfect. Can you also update https://github.com/pybind/pybind11/blob/master/include/pybind11/pybind11.h#L512 to switch to the new API?

Done. Thanks for the review!

@rwgk rwgk merged commit 2fb3d7c into pybind:master Jun 27, 2023
@rwgk rwgk deleted the capsule_name branch June 27, 2023 22:08
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Jun 27, 2023
@rwgk rwgk removed the needs changelog Possibly needs a changelog entry label Jul 15, 2023
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