Add PyUnstable_Object_IsUniquelyReferenced#149
Conversation
5020859 to
02628ac
Compare
vstinner
left a comment
There was a problem hiding this comment.
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
| } | ||
| #endif | ||
|
|
||
| #ifndef PYPY_VERSION |
There was a problem hiding this comment.
The function doesn't make sense on PyPy?
There was a problem hiding this comment.
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.
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_IsUniquelyReferencedand 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
PyUnstablefunctions in the compat headers.The implementation is copy/pasted from the implementation of
_PyObject_IsUniquelyReferenced.