gh-137791: Improve documentation for the reference counting changes in 3.14 #137819
gh-137791: Improve documentation for the reference counting changes in 3.14 #137819ZeroIntensity wants to merge 5 commits intopython:mainfrom
Conversation
|
I don't know if this is what the OP actually meant. Negative reference counts might not be caused by the I hope the OP responds soon what they actually mean, and point to an actual issue/code. |
Agreed. I'm trying to clarify that the borrowed reference changes only affect code in very niche cases. |
Doc/whatsnew/3.14.rst
Outdated
| references <strong reference>` is avoided in the Python interpreter. This | ||
| generally does not affect existing code, but C API extensions that checked | ||
| :c:func:`Py_REFCNT` of ``1`` to determine if an object is not referenced by | ||
| any other code should instead use :c:func:`PyUnstable_Object_IsUniqueReferencedTemporary` |
There was a problem hiding this comment.
It doesn't feel great to suggest people move from a (theoretically) stable Py_REFCNT(op) == 1 to an explicitly unstable PyUnstable_ function.
Can we explain why the function we suggest users port to is marked as unstable (e.g. that in reality, Py_REFCNT(op) == 1 was less stable than it appeared?).
Per Petr's comment on the issue, if this is strictly a breaking change, the note in refcounting.rst should probably be more explicit that in previous versions, the semantics around 1 and 0 were guaranteed, but that they no longer are.
There was a problem hiding this comment.
0 is still guaranteed, as far as I know. I'll do my best to make things clearer otherwise.
There was a problem hiding this comment.
I've updated both notes. Let me know if that looks any better.
| references <strong reference>` is avoided in the Python interpreter. | ||
|
|
||
| This means that in Python 3.14, the :term:`reference count` of an object can | ||
| be ``1`` even when an object has more than one reference in the interpreter |
There was a problem hiding this comment.
Nitpick:
| be ``1`` even when an object has more than one reference in the interpreter | |
| be ``1`` even when the object has more than one reference in the interpreter |
There was a problem hiding this comment.
I think the current wording is fine. It's not clear to me what "the object" would refer to, because there isn't an example.
There was a problem hiding this comment.
I think "the object" is refer to "the :term:reference count of an object" just in this sentence, but I know this is a nitpick, so current wording is totally fine to me.
|
Should we also make changes to this docs? Lines 914 to 918 in d396a32 |
|
I don't think there was much of an appetite for documenting this, so I'm going to close this. |
📚 Documentation preview 📚: https://cpython-previews--137819.org.readthedocs.build/