Skip to content

Make it clear Py_VISIT is a macro in the docs#133688

Merged
kumaraditya303 merged 2 commits into
python:mainfrom
da-woods:visit-docs
May 18, 2025
Merged

Make it clear Py_VISIT is a macro in the docs#133688
kumaraditya303 merged 2 commits into
python:mainfrom
da-woods:visit-docs

Conversation

@da-woods

@da-woods da-woods commented May 8, 2025

Copy link
Copy Markdown
Contributor

It has the hidden return inside it, so to me the void return type is a little misleading because it implies that it behaves like a C function.


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

It has the hidden return inside it, so to me the `void` return type is a little misleading because it implies that it behaves like a C function.
Comment thread Doc/c-api/gcsupport.rst Outdated

@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.

There are a few other places where a function is documented instead of a macro, e.g. any of the reference count APIs. I'm not opposed to changing everything, but what's the benefit here?

@ZeroIntensity

Copy link
Copy Markdown
Member

Oh wait, bad example--the reference count APIs are static inline functions, not macros. Oops. Pretend I said Py_CLEAR.

@da-woods

Copy link
Copy Markdown
Contributor Author

There are a few other places where a function is documented instead of a macro, e.g. any of the reference count APIs. I'm not opposed to changing everything, but what's the benefit here?

My opinion is that most of the reference counting API could be substituted for a function (and in some cases, has been). The ones that really couldn't be replaced by a function like Py_SETREF are documented as macros.

Py_VISIT couldn't be implemented as a function because it has a return in it, and that's what I found confusing about the way it's currently documented.

Oh wait, bad example--the reference count APIs are static inline functions, not macros. Oops. Pretend I said Py_CLEAR.

My opinion would be that Py_CLEAR might be better documented as a macro.


I don't feel hugely strongly about this - I'm not going to argue if you don't think it's an improvement. But that's the reasoning for why I proposed the change.

@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.

Ok, yeah, let's go with this. Py_VISIT can return the caller, which isn't at all clear when it's documented as a function. Let's also fix Py_CLEAR in a follow-up.

@ZeroIntensity ZeroIntensity added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels May 11, 2025
@ZeroIntensity ZeroIntensity requested a review from encukou May 11, 2025 16:53
@kumaraditya303 kumaraditya303 merged commit bb32f3c into python:main May 18, 2025
36 checks passed
@miss-islington-app

Copy link
Copy Markdown

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

@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs May 18, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 18, 2025
(cherry picked from commit bb32f3c)

Co-authored-by: da-woods <dw-git@d-woods.co.uk>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 18, 2025
(cherry picked from commit bb32f3c)

Co-authored-by: da-woods <dw-git@d-woods.co.uk>
@bedevere-app

bedevere-app Bot commented May 18, 2025

Copy link
Copy Markdown

GH-134186 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 May 18, 2025
@bedevere-app

bedevere-app Bot commented May 18, 2025

Copy link
Copy Markdown

GH-134187 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 May 18, 2025
@da-woods da-woods deleted the visit-docs branch May 18, 2025 16:29
kumaraditya303 pushed a commit that referenced this pull request May 18, 2025
document `Py_VISIT` as a macro in the docs (GH-133688)
(cherry picked from commit bb32f3c)

Co-authored-by: da-woods <dw-git@d-woods.co.uk>
kumaraditya303 pushed a commit that referenced this pull request May 18, 2025
document `Py_VISIT` as a macro in the docs (GH-133688)
(cherry picked from commit bb32f3c)

Co-authored-by: da-woods <dw-git@d-woods.co.uk>
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants