Skip to content

Commit 2701e8e

Browse files
miss-islingtonYashp002StanFromIrelandpicnixzZeroIntensity
authored
[3.13] gh-141004: Document Py_ARRAY_LENGTH (GH-141601) (GH-141896)
gh-141004: Document `Py_ARRAY_LENGTH` (GH-141601) (cherry picked from commit e0773ea) Co-authored-by: Yashraj <[email protected]> Co-authored-by: Stan Ulbrych <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]> Co-authored-by: Peter Bierma <[email protected]>
1 parent ce40ad0 commit 2701e8e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Doc/c-api/intro.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,19 @@ complete listing.
326326
PyDoc_VAR(python_doc) = PyDoc_STR("A genus of constricting snakes in the Pythonidae family native "
327327
"to the tropics and subtropics of the Eastern Hemisphere.");
328328

329+
.. c:macro:: Py_ARRAY_LENGTH(array)
330+
331+
Compute the length of a statically allocated C array at compile time.
332+
333+
The *array* argument must be a C array with a size known at compile time.
334+
Passing an array with an unknown size, such as a heap-allocated array,
335+
will result in a compilation error on some compilers, or otherwise produce
336+
incorrect results.
337+
338+
This is roughly equivalent to::
339+
340+
sizeof(array) / sizeof((array)[0])
341+
329342

330343
.. _api-objects:
331344

0 commit comments

Comments
 (0)