-
-
Notifications
You must be signed in to change notification settings - Fork 33
Add PyUnstable_TryIncref and PyUnstable_EnableTryIncRef. #159
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
Conversation
tests/test_pythoncapi_compat_cext.c
Outdated
| return -1; | ||
| } | ||
| #endif | ||
| MyType.tp_name = "MyType"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please use a less generic name, such as TryIncrefType? (for the variable name and the type name)
|
I'm fine with adding these two functions. I just have some suggestions on the implementation. |
Co-authored-by: Victor Stinner <vstinner@python.org>
tests/test_pythoncapi_compat_cext.c
Outdated
| static int MyObject_dealloc_called = 0; | ||
|
|
||
| static void | ||
| MyObject_dealloc(PyObject *op) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind to rename it to TryIncref_dealloc() and rename also MyObject_dealloc_called?
|
Merged, thanks for your contribution. |
These would be useful in PyTorch, which uses pythoncapi-compat.h. They are also already used in pybind11, which doesn't use pythoncapi-compat.h.