Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Doc/c-api/structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,21 @@ Macro name C type Python type

Always ``None``. Must be used with :c:macro:`Py_READONLY`.

.. c:macro:: Py_ARRAY_LENGTH(array)

Compute the length (number of elements) of a statically allocated C array at
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 macro is defined as::

#define Py_ARRAY_LENGTH(array) (sizeof(array) / sizeof((array)[0]))
Copy link
Member

Choose a reason for hiding this comment

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

Technically, this is wrong since depending on the GCC version it varies.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, let's just say something like "This is generally equivalent to ..."


.. versionadded:: 3.13
Copy link
Member

@StanFromIreland StanFromIreland Nov 15, 2025

Choose a reason for hiding this comment

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

This is wrong, it has been around for many years (2.7 & before).



Comment on lines +733 to +734
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

Unrelated changes.

Defining Getters and Setters
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
Loading