gh-129675: Update documentation for tp_basicsize & tp_itemsize#129850
Conversation
- Add alignment requirement - Mention that ob_size is unreliable if you don't control it - Add some links for context - basicsize should include the base type in generaly not just PyObject This adds a “by-the-way” link to `PyObject_New`, which shouldn't be used for GC types. In order to be comfortable linking to it, I also add a link to `PyObject_GC_New` from its docs. And the same for `*Var` variants, while I'm here.
| exceptions: for example, ints use a negative :c:member:`~PyVarObject.ob_size` to indicate a | ||
| negative number, and N is ``abs(ob_size)`` there. Also, the presence of an |
There was a problem hiding this comment.
@markshannon FWIW, here's another piece of documentation that says abs(ob_size) gives you the size of a PyLongObject.
ZeroIntensity
left a comment
There was a problem hiding this comment.
Mostly LGTM. Feel free to ignore any of my comments, these are pretty much just what I thought to myself as I read through it.
encukou
left a comment
There was a problem hiding this comment.
Thanks for the review!
Things can always be improved, but it looks like this iteration is good to go.
|
Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
|
Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…ythonGH-129850) * Update documentation for tp_basicsize & tp_itemsize - Add alignment requirement - Mention that ob_size is unreliable if you don't control it - Add some links for context - basicsize should include the base type in generaly not just PyObject This adds a “by-the-way” link to `PyObject_New`, which shouldn't be used for GC types. In order to be comfortable linking to it, I also add a link to `PyObject_GC_New` from its docs. And the same for `*Var` variants, while I'm here. * Strongly suggest Py_SIZE & Py_SET_SIZE (cherry picked from commit ad0f618) Co-authored-by: Petr Viktorin <encukou@gmail.com>
|
GH-131078 is a backport of this pull request to the 3.12 branch. |
…ythonGH-129850) * Update documentation for tp_basicsize & tp_itemsize - Add alignment requirement - Mention that ob_size is unreliable if you don't control it - Add some links for context - basicsize should include the base type in generaly not just PyObject This adds a “by-the-way” link to `PyObject_New`, which shouldn't be used for GC types. In order to be comfortable linking to it, I also add a link to `PyObject_GC_New` from its docs. And the same for `*Var` variants, while I'm here. * Strongly suggest Py_SIZE & Py_SET_SIZE (cherry picked from commit ad0f618) Co-authored-by: Petr Viktorin <encukou@gmail.com>
|
GH-131079 is a backport of this pull request to the 3.13 branch. |
…GH-129850) (GH-131078) - Add alignment requirement - Mention that ob_size is unreliable if you don't control it - Add some links for context - basicsize should include the base type in generaly not just PyObject - suggest Py_SIZE & Py_SET_SIZE This adds a “by-the-way” link to `PyObject_New`, which shouldn't be used for GC types. In order to be comfortable linking to it, I also add a link to `PyObject_GC_New` from its docs. And the same for `*Var` variants, while I'm here. (cherry picked from commit ad0f618) Co-authored-by: Petr Viktorin <encukou@gmail.com>
…GH-129850) (GH-131079) - Add alignment requirement - Mention that ob_size is unreliable if you don't control it - Add some links for context - basicsize should include the base type in generaly not just PyObject - suggest Py_SIZE & Py_SET_SIZE This adds a “by-the-way” link to `PyObject_New`, which shouldn't be used for GC types. In order to be comfortable linking to it, I also add a link to `PyObject_GC_New` from its docs. And the same for `*Var` variants, while I'm here. (cherry picked from commit ad0f618) Co-authored-by: Petr Viktorin <encukou@gmail.com>
This adds a “by-the-way” link to
PyObject_New, which shouldn't be used for GC types. In order to be comfortable linking to it, I also add a link toPyObject_GC_Newfrom its docs. And the same for*Varvariants, while I'm here.📚 Documentation preview 📚: https://cpython-previews--129850.org.readthedocs.build/