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

Improve API/implementation for HPyCapsule_Destructor #378

Merged
merged 6 commits into from
Nov 23, 2022

Conversation

fangerer
Copy link
Contributor

This resolved #377.
In this PR, I'm introducing macro HPyDef_CAPSULE_DESTRUCTOR (much like HPyDev_METH macro) and removing HPyCapsule_GetDestructor. With this, we can significantly simplify our capsule implementation because we never need to hand out the HPy capsule destructor function while the new macro will generate an appropriate CPython trampoline.

Removing HPyCapsule_GetDestructor should be fine since I didn't find a single usage of PyCapsule_GetDestructor in the C code of the top4000 packages.

@mattip
Copy link
Contributor

mattip commented Nov 23, 2022

LGTM, but will defer to @antocuni

Copy link
Collaborator

@antocuni antocuni left a comment

Choose a reason for hiding this comment

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

LGTM, apart the name of the macro: the idea of the various existing HPyDef_* macros is that each of them defines a static variable whose C type is actually HPyDef.

HPyDef_CAPSULE_DESTRUCTOR does something different, so it should be named differently; it belongs to the HPyCapsule "namespace", so what about HPyCapsule_DESTRUCTOR?

test/test_capsule.py Outdated Show resolved Hide resolved
@fangerer
Copy link
Contributor Author

LGTM, apart the name of the macro: the idea of the various existing HPyDef_* macros is that each of them defines a static variable whose C type is actually HPyDef.

HPyDef_CAPSULE_DESTRUCTOR does something different, so it should be named differently; it belongs to the HPyCapsule "namespace", so what about HPyCapsule_DESTRUCTOR?

Okay, I'm not objected to rename it. I did that for consistency but didn't have in mind that the HPyDef_* prefix is because of the HPyDef type.

Copy link
Collaborator

@antocuni antocuni left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@fangerer fangerer merged commit ff1488d into hpyproject:master Nov 23, 2022
@fangerer fangerer deleted the fa/capsule_dtor branch November 23, 2022 17:28
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.

Improve the API/implementation for HPyCapsule_Destructor
3 participants