Skip to content

Commit cf93360

Browse files
committed
Move Py_ARRAY_LENGTH to Useful macros, use 'generally equivalent'
1 parent 424d959 commit cf93360

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

Doc/c-api/intro.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,18 @@ 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+
316+
sizeof(array) / sizeof((array)[0])
317+
306318

307319
.. _api-objects:
308320

Doc/c-api/structures.rst

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -730,20 +730,7 @@ 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-
733+
747734
748735
Defining Getters and Setters
749736
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)