Skip to content

Commit 424d959

Browse files
committed
gh-141004: Document Py_ARRAY_LENGTH macro
1 parent 85f3009 commit 424d959

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Doc/c-api/structures.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,21 @@ Macro name C type Python type
730730
731731
Always ``None``. Must be used with :c:macro:`Py_READONLY`.
732732
733+
.. c:macro:: Py_ARRAY_LENGTH(array)
734+
735+
Compute the length (number of elements) of a statically allocated C array at
736+
compile time.
737+
738+
The *array* argument must be a C array with a size known at compile time,
739+
not a pointer. Using this macro with a pointer will produce incorrect results.
740+
741+
This macro is defined as::
742+
743+
#define Py_ARRAY_LENGTH(array) (sizeof(array) / sizeof((array)[0]))
744+
745+
.. versionadded:: 3.13
746+
747+
733748
Defining Getters and Setters
734749
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
735750

0 commit comments

Comments
 (0)