This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Document the Py_SIZE() macro.
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: beng94, berker.peksag, docs@python, gregory.p.smith, python-dev
Priority: normal Keywords: easy

Created on 2014-07-09 19:44 by gregory.p.smith, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg222633 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2014-07-09 19:44
The Py_SIZE() macro is not documented.  It should be.  It is very useful along with PyList_New(positive_number) after using PyList_SET_ITEM() to fill in up to the first positive_number elements of a list object in the most optimal manner by avoiding numerous redundant array resizes and error checks along the away.

The Py_SIZE() macro was introduced (in 2.6 I believe) and is specifically intended for use as an lvalue (see http://bugs.python.org/issue1724 to confirm that).  It currently has uses in several places in CPython's core and modules as well as within some third party extension modules and tools such as Cython).
msg258821 - (view) Author: Tamás Bence Gedai (beng94) * Date: 2016-01-22 16:27
Py_SIZE: https://docs.python.org/3.5/c-api/structures.html#c.Py_SIZE
PyList_New: https://docs.python.org/3.5/c-api/list.html#c.PyList_New

I think they're documented now, so I guess the issue can be closed.
msg258825 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-01-22 16:43
Thanks for triaging! The relevant commit is 760c5cfacbaa.
msg258837 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-01-22 21:17
New changeset 63183596db79 by Gregory P. Smith in branch '2.7':
Per issue21949 and issue1629: Document the Py_SIZE, Py_TYPE, Py_REFCNT macros.
https://hg.python.org/cpython/rev/63183596db79
History
Date User Action Args
2022-04-11 14:58:05adminsetgithub: 66148
2016-01-22 21:18:28gregory.p.smithsetresolution: out of date -> fixed
2016-01-22 21:17:59python-devsetnosy: + python-dev
messages: + msg258837
2016-01-22 16:43:52berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg258825

resolution: out of date
stage: needs patch -> resolved
2016-01-22 16:27:42beng94setnosy: + beng94
messages: + msg258821
2014-10-19 18:33:08berker.peksagsettype: performance -> enhancement
stage: needs patch
2014-07-09 19:44:44gregory.p.smithcreate