◐ Shell
reader mode source ↗
Skip to content

gh-141004: Document Py_ARRAY_LENGTH macro#141601

Merged
ZeroIntensity merged 12 commits into
python:mainfrom
Yashp002:main
Nov 24, 2025
Merged

gh-141004: Document Py_ARRAY_LENGTH macro#141601
ZeroIntensity merged 12 commits into
python:mainfrom
Yashp002:main

Conversation

@Yashp002

@Yashp002 Yashp002 commented Nov 15, 2025

Copy link
Copy Markdown
Contributor

This PR adds documentation for the Py_ARRAY_LENGTH macro to the C API documentation, addressing issue #141004.

The documentation is placed in the "Useful macros" section of Doc/c-api/intro.rst and includes:

  • A description of the macro's purpose (computing array length at compile time)
  • A warning that it must be used with C arrays, not pointers
  • An explanation that it's equivalent to sizeof(array) / sizeof((array)[0])

This macro has existed since Python 2.7 but was previously undocumented in the official C API documentation.


📚 Documentation preview 📚: https://cpython-previews--141601.org.readthedocs.build/

Added documentation for the Py_ARRAY_LENGTH macro, explaining its usage and requirements.
@StanFromIreland StanFromIreland changed the title Document Py_ARRAY_LENGTH macro in intro.rst Nov 15, 2025
@StanFromIreland

Copy link
Copy Markdown
Member

Our CI does not like it when the branch the PR is opened from is called "main" IIRC and that is why some extra tests are running.

Yashp002 and others added 3 commits November 16, 2025 02:09
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
@Yashp002

Copy link
Copy Markdown
Contributor Author

Also, is it a generally good practice to break off a branch from the main while working on it myself then?

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
@picnixz picnixz changed the title gh-141004: Document Py_ARRAY_LENGTH macro in intro.rst Nov 16, 2025
Removed redundant explanation of array size calculation.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

Happy to see a new contributor :)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
@Yashp002

Copy link
Copy Markdown
Contributor Author

Happy to see a new contributor :)

Thanks, I've been hoping to contribute to python since the longest time tbh 😄

@ZeroIntensity

Copy link
Copy Markdown
Member

Please address my comments and then I'll merge this.

Yashp002 and others added 3 commits November 20, 2025 23:50
I realize that VLAs also don't have a known size at compile-time.

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

LGTM.

@ZeroIntensity ZeroIntensity enabled auto-merge (squash) November 24, 2025 13:30
@ZeroIntensity ZeroIntensity added needs backport to 3.13 bugs and security fixes bugs and security fixes labels Nov 24, 2025

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

LGTM

Hide details View details @ZeroIntensity ZeroIntensity merged commit e0773ea into python:main Nov 24, 2025
36 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Nov 24, 2025
@miss-islington-app

Copy link
Copy Markdown

Thanks @Yashp002 for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 24, 2025
(cherry picked from commit e0773ea)

Co-authored-by: Yashraj <yashrajpala8@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
@bedevere-app

bedevere-app Bot commented Nov 24, 2025

Copy link
Copy Markdown

GH-141895 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 24, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 24, 2025
(cherry picked from commit e0773ea)

Co-authored-by: Yashraj <yashrajpala8@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
@bedevere-app

bedevere-app Bot commented Nov 24, 2025

Copy link
Copy Markdown

GH-141896 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Nov 24, 2025
@ZeroIntensity

Copy link
Copy Markdown
Member

Congrats on your first contribution @Yashp002 :)

ZeroIntensity added a commit that referenced this pull request Nov 24, 2025
gh-141004: Document `Py_ARRAY_LENGTH` (GH-141601)
(cherry picked from commit e0773ea)

Co-authored-by: Yashraj <yashrajpala8@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
ZeroIntensity added a commit that referenced this pull request Nov 24, 2025
gh-141004: Document `Py_ARRAY_LENGTH` (GH-141601)
(cherry picked from commit e0773ea)

Co-authored-by: Yashraj <yashrajpala8@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
StanFromIreland added a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
ashm-dev pushed a commit to ashm-dev/cpython that referenced this pull request Dec 8, 2025
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants