-
-
Notifications
You must be signed in to change notification settings - Fork 33
Add PyUnstable_Object_IsUniquelyReferenced #149
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
5020859
to
02628ac
Compare
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 rebase your PR on the updated main branch to get tests on Free Threaded builds?
tests/test_pythoncapi_compat_cext.c
Outdated
@@ -1953,6 +1953,28 @@ test_unicodewriter_format(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) | |||
} | |||
#endif | |||
|
|||
#ifndef PYPY_VERSION |
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.
The function doesn't make sense on PyPy?
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.
Apparently not, maybe an interned string? I rewrote it to use an empty tuple and that seems to work on PyPy.
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.
I rewrote it to use an empty tuple and that seems to work on PyPy.
but that seems to have broken other builds, let me see if I can get it working everywhere...
Tests fail on Python 2:
|
I guess empty tuples have had reference counting optimizations for a long time! |
Please update also the doc:
|
Merged, thanks for your contribution. I'm not very excited by adding |
Adds a shim for
PyUnstable_Object_IsUniquelyReferenced
and a test for the shim.I'd like to use this function in a few libraries but don't want to have to have a thread-unsafe check in 3.13 or add new uses of internal headers outside of the compat header here.
I'm not sure whether the using stuff from internal headers is ok in a shim like this. I'm also not sure if you want to avoid
PyUnstable
functions in the compat headers.The implementation is copy/pasted from the implementation of
_PyObject_IsUniquelyReferenced
.