gh-141004: Document Py_ARRAY_LENGTH macro#141598
gh-141004: Document Py_ARRAY_LENGTH macro#141598Yashp002 wants to merge 3 commits intopython:mainfrom
Conversation
Doc/c-api/structures.rst
Outdated
| This macro is defined as:: | ||
|
|
||
| #define Py_ARRAY_LENGTH(array) (sizeof(array) / sizeof((array)[0])) |
There was a problem hiding this comment.
Technically, this is wrong since depending on the GCC version it varies.
There was a problem hiding this comment.
Yeah, let's just say something like "This is generally equivalent to ..."
Doc/c-api/structures.rst
Outdated
|
|
||
| #define Py_ARRAY_LENGTH(array) (sizeof(array) / sizeof((array)[0])) | ||
|
|
||
| .. versionadded:: 3.13 |
There was a problem hiding this comment.
This is wrong, it has been around for many years (2.7 & before).
| In previous versions, the macros were only available with | ||
| ``#include "structmember.h"`` and were named without the ``Py_`` prefix | ||
| (e.g. as ``T_INT``). | ||
| The header is still available and contains the old names, along with | ||
| the following deprecated types: | ||
|
|
||
| .. c:macro:: T_OBJECT | ||
|
|
||
| Like ``Py_T_OBJECT_EX``, but ``NULL`` is converted to ``None``. | ||
| This results in surprising behavior in Python: deleting the attribute | ||
| effectively sets it to ``None``. |
There was a problem hiding this comment.
Why is it in this section? Useful macros seems to be a better place IMO.
|
Thanks @StanFromIreland for the review, Fixing all three issues now: Moving to Useful macros section Removing versionadded tag (my mistake on the version) Changing to "generally equivalent to" for the definition |
|
Something odd happened and the CI broke :-( |
| @@ -1 +1 @@ | |||
| ../../Lib/_colorize.py No newline at end of file | |||
| ../../Lib/_colorize.py | |||
There was a problem hiding this comment.
Oh, I take that back, this happened and the CI broke, please revert unrelated changes.
|
|
||
|
|
There was a problem hiding this comment.
Unrelated changes.
|
right sorry gimme a minute, it's my first PR actually 😭 |
Indeed, but you have made changes to their configuration files too, see my review above, please revert the unrelated changes. |
|
I'm closing this to submit clean version in a couple of minutes and actively awaiting review. |
Fixes part of #141004
Added documentation for the
Py_ARRAY_LENGTHmacro in Doc/c-api/structures.rst. This macro computes the length of a statically allocated C array at compile time.The documentation includes:
📚 Documentation preview 📚: https://cpython-previews--141598.org.readthedocs.build/