Skip to content
13 changes: 13 additions & 0 deletions Doc/c-api/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,19 @@ complete listing.
PyDoc_VAR(python_doc) = PyDoc_STR("A genus of constricting snakes in the Pythonidae family native "
"to the tropics and subtropics of the Eastern Hemisphere.");

.. c:macro:: Py_ARRAY_LENGTH(array)

Compute the length (number of elements) of a statically allocated C array at
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's generally well known that the length is the number of elements.

compile time.

The *array* argument must be a C array with a size known at compile time,
not a pointer. Using this macro with a pointer will produce incorrect results.

This is generally equivalent to::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the use of "generally" equivalent because it may indicate that it's equivalent to something else. So I would remove the "This is generally equivalent to:: + code"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, it's helpful to have something rather than nothing, even if it's not 100% true. This is a good example of a lie-to-children.

If you're against "generally", how about saying "this is semantically equivalent to ..."?

Copy link
Member

@picnixz picnixz Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"generally" is inaccurate; if you want to lie a bit, you should say "roughly equivalent to" (which is what we do in academia or in itertools btw). "Generally" means that this would always be the case (at least to me when used like that), but the macro expansion is different.

  • If you want to use "generally" as a synonym of "usually", "roughly" is better.
  • "semantically equivalent" is too verbose IMO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"roughly equivalent to" is fine with me.


sizeof(array) / sizeof((array)[0])



.. _api-objects:

Expand Down
Loading