-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
gh-141004: Document Py_ARRAY_LENGTH macro #141598
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, this is wrong since depending on the GCC version it varies.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 | |||
| ../../Lib/_colorize.py | |||
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.
Oh, I take that back, this happened and the CI broke, please revert unrelated changes.
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.
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/