-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-135913: Document ob_refcnt, ob_type, ob_size #135914
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
.. c:member:: Py_ssize_t ob_refcnt | ||
|
||
The object's reference count, as returned by :c:macro:`Py_REFCNT`. | ||
Do not use this field directly; instead use functions and macros such as | ||
:c:macro:`!Py_REFCNT`, :c:func:`Py_INCREF` and :c:func:`Py_DecRef`. |
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 don't think this is accurate anymore:
Lines 128 to 146 in a88b49c
union { | |
#if SIZEOF_VOID_P > 4 | |
PY_INT64_T ob_refcnt_full; /* This field is needed for efficient initialization with Clang on ARM */ | |
struct { | |
# if PY_BIG_ENDIAN | |
uint16_t ob_flags; | |
uint16_t ob_overflow; | |
uint32_t ob_refcnt; | |
# else | |
uint32_t ob_refcnt; | |
uint16_t ob_overflow; | |
uint16_t ob_flags; | |
# endif | |
}; | |
#else | |
Py_ssize_t ob_refcnt; | |
#endif | |
_Py_ALIGNED_DEF(_PyObject_MIN_ALIGNMENT, char) _aligner; | |
}; |
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.
Hm, yes, the type isn't Py_ssize_t
any more.
That's an issue in the current documentation too; guess it's time to reopen #125174 for a docs update.
Similarly, a lot of the docs talk about PyObject_HEAD_INIT
setting the refcount to 1. I can't fix everything in this PR...
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.
Sphinx needs a type for .. c:member:
. I don't think I can do better than the note below.
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.
You may mention Py_SET_REFCNT() as well.
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 think all of the others from the refcounting page (Py_XINCREF
, Py_CLEAR
, etc.) should be mentioned before Py_SET_REFCNT
. The “such as” is intended to cover these.
.. c:member:: Py_ssize_t ob_refcnt | ||
|
||
The object's reference count, as returned by :c:macro:`Py_REFCNT`. | ||
Do not use this field directly; instead use functions and macros such as | ||
:c:macro:`!Py_REFCNT`, :c:func:`Py_INCREF` and :c:func:`Py_DecRef`. |
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.
You may mention Py_SET_REFCNT() as well.
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.
LGTM
Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
* pythongh-135913: Document ob_refcnt, ob_type, ob_size In `typeobj.rst`, instead of `:c:member:` it would be better to use `.. c:member::` with a `:no-index:` option, see: See ref. https://www.sphinx-doc.org/en/master/usage/domains/index.html#basic-markup However, `c:member` currently does not support `:no-index:`. (cherry picked from commit 73e1207) Co-authored-by: Petr Viktorin <encukou@gmail.com>
GH-136377 is a backport of this pull request to the 3.14 branch. |
…H-136377) gh-135913: Document ob_refcnt, ob_type, ob_size (GH-135914) * gh-135913: Document ob_refcnt, ob_type, ob_size In `typeobj.rst`, instead of `:c:member:` it would be better to use `.. c:member::` with a `:no-index:` option, see: See ref. https://www.sphinx-doc.org/en/master/usage/domains/index.html#basic-markup However, `c:member` currently does not support `:no-index:`. (cherry picked from commit 73e1207) Co-authored-by: Petr Viktorin <encukou@gmail.com>
* pythongh-135913: Document ob_refcnt, ob_type, ob_size In `typeobj.rst`, instead of `:c:member:` it would be better to use `.. c:member::` with a `:no-index:` option, see: See ref. https://www.sphinx-doc.org/en/master/usage/domains/index.html#basic-markup However, `c:member` currently does not support `:no-index:`.
* pythongh-135913: Document ob_refcnt, ob_type, ob_size In `typeobj.rst`, instead of `:c:member:` it would be better to use `.. c:member::` with a `:no-index:` option, see: See ref. https://www.sphinx-doc.org/en/master/usage/domains/index.html#basic-markup However, `c:member` currently does not support `:no-index:`.
📚 Documentation preview 📚: https://cpython-previews--135914.org.readthedocs.build/