You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add bindings for new PyUnstable APIs in 3.14 #5386
Replaces uses of Py_REFCNT(obj) == 1. This is needed for certain optimizations and it'd be nice to be able to do those optimizations safely on the free-threaded build.
More niche, used to detect uniquely referenced temporaries created by certain Python bytecode operations. NumPy uses this along with some code to scan the call stack to elide temporaries that are created by NumPy internals or by Python bytecode. It's pretty cursed. There are probably less cursed ways to use this.
See the docs for PyUnstable_TryIncRef. This is needed in some advanced cases to properly handle weak references without lots of overhead. I think there are other cases as well.
Activity
ngoldbaum commentedon Sep 1, 2025
I created a C backport for
IsUniquelyReferenced, see: python/pythoncapi-compat#149That might be useful for inspiration if anyone wants to write a safe wrapper that works on older Python versions.