Skip to content

gh-141004: Reorganize and reword the 'Useful macros' section#144471

Open
encukou wants to merge 7 commits intopython:mainfrom
encukou:doc-useful-macros
Open

gh-141004: Reorganize and reword the 'Useful macros' section#144471
encukou wants to merge 7 commits intopython:mainfrom
encukou:doc-useful-macros

Conversation

@encukou
Copy link
Member

@encukou encukou commented Feb 4, 2026

This is a follow-up to #143508. When all the public macros were documented, the section became somewhat unwieldy.

  • Group the macros
  • Roughly order them to put the most important ones first
  • Add expansions where it makes sense; especially if there's an equivalent in modern C or a common compiler

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

- Group the macros
- Roughly order them to put the most important ones first
- Add expansions where it makes sense; especially if there's
  an equivalent in modern C or a common compiler
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

Since you're already moving many functions, it may be interesting to sort functions in each category.


A use for ``Py_UNREACHABLE()`` is following a call a function that
never returns but that is not declared :c:macro:`_Py_NO_RETURN`.
never returns but that is not declared ``_Noreturn``.
Copy link
Member

Choose a reason for hiding this comment

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

Note: C11 added _Noreturn, but C23 adds [[noreturn]] and deprecates _Noreturn.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm aware, but don't want to get in the details too much.
We require C11, and as far as I know, deprecations in the C standard don't mean planned removal.

encukou and others added 2 commits February 4, 2026 15:35
Co-authored-by: Victor Stinner <vstinner@python.org>
@encukou
Copy link
Member Author

encukou commented Feb 4, 2026

it may be interesting to sort functions in each category

Sort by what?
IMO, sorting by relevance works great, even though it's not objective.

@vstinner
Copy link
Member

vstinner commented Feb 4, 2026

Sort by what?

I'm thinking at the alphabetical order.

@ZeroIntensity
Copy link
Member

Sorry, I just caused conflicts here with #144279.

@encukou
Copy link
Member Author

encukou commented Feb 5, 2026

More macros -- more structure. How does this version look?

I've grouped them in categories, and sorted by relevance first, alphabet second. For example, Py_MAX/Py_MIN before Py_CHARMASK.

FWIW, I think combined entries are a great way to reduce duplication for things that do almost the same thing: Py_MAX & Py_MIN, Py_LL & Py_ULL. Sorting alphabetically would make these harder to find.

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, with two little things below.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. I like the new organization.

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

LGTM as well, thanks for the cleanup!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants