Skip to content

Commit 7c24a14

Browse files
authored
Document Py_ARRAY_LENGTH macro in intro.rst
Added documentation for the Py_ARRAY_LENGTH macro, explaining its usage and requirements.
1 parent 85f3009 commit 7c24a14

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Doc/c-api/intro.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,16 @@ complete listing.
303303
PyDoc_VAR(python_doc) = PyDoc_STR("A genus of constricting snakes in the Pythonidae family native "
304304
"to the tropics and subtropics of the Eastern Hemisphere.");
305305

306+
.. c:macro:: Py_ARRAY_LENGTH(array)
307+
308+
Compute the length (number of elements) of a statically allocated C array at
309+
compile time.
310+
311+
The *array* argument must be a C array with a size known at compile time,
312+
not a pointer. Using this macro with a pointer will produce incorrect results.
313+
314+
This is generally equivalent to::
315+
sizeof(array) / sizeof((array)[0])
306316

307317
.. _api-objects:
308318

0 commit comments

Comments
 (0)