Skip to content

Conversation

encukou
Copy link
Member

@encukou encukou commented Aug 20, 2025

The motivation here is to avoid users reading PEP 7 as guarantees about what compilers/settings are required to build Python or extensions.

I've also clarified a few things in line with current practice. (And I couldn't resist some alliteration, lmk if suit & tie is required.)


📚 Documentation preview 📚: https://pep-previews--4557.org.readthedocs.build/pep-0007/

The motivation here is to avoid users reading PEP 7 as guarantees about
what compilers/settings are required to build Python or extensions.

I've also clarified a few things in line with current practice.
Comment on lines +60 to +61
Common C code conventions
=========================
Copy link
Member

@AA-Turner AA-Turner Aug 21, 2025

Choose a reason for hiding this comment

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

Any alliteration appropriate? Always, and all allotted alliteration allowance assured as apportioned! All adults are alliteration acclimatised as affably attested, accidental amelioration & aggravation apart. Avid alliterators adept at alliteration advance: abruptly, audaciously, ambitiously, and admirably!

Ahoy!

A

@AA-Turner
Copy link
Member

Alliterative and approved!

A

Co-authored-by: Adam Turner <[email protected]>
@encukou
Copy link
Member Author

encukou commented Aug 22, 2025

@warsaw & @gvanrossum, do you have thoughts on this?

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Good improvements overall!

There were two places where I didn't understand what you meant.

I also find it slightly odd to write prescriptive language (e.g. "should be compatible") while at the same time defending that with"but the intro allows exceptions". I'd rather weaken the language somewhat ("ought to"?), in the sake of clarity.

Comment on lines 33 to 34
For features that aren't in the relevant standard (like atomics or some C11
features in public headers), use CPython-specific wrappers.
Copy link
Member

Choose a reason for hiding this comment

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

I had to follow the wikipedia link to optional features below to understand this. The point is that certain features are declared optional by the standard, and for those, if we want to use them, we must use CPython-specific headers. (But why not allow checking the standard's feature-check macros directly, if the main code just has to have two versions? Wrappers are useful if you'd be checking for the feature-check macros repeatedly (like with atomics) or if a shorthand macro could help not seeing the feature checks at all in the rest of the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not only about optional features. See #define Py_ARITHMETIC_RIGHT_SHIFT for a nice example.

As for why wrappers:
If a wrapper already exists, you should of course use it. If it does not, you're in for a compiler compatibility study -- and the best place for the results of that is a comment on top of a macro, even if the macro is simple.

New C features tend to be added after a few implementations already exist as compiler extension, so many cases there are (almost) equivalent extensions we need to check as well. For things we add in the future, I expect that variants for GCC, MSVC & standard -- like with atomics -- will be quite normal.


I'll add examples here, they should make things clearer.

Comment on lines 42 to 43
(This is more restrictive than what we guarantee users. Remember that this PEP
allows exceptions!)
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand what this means. Maybe a brief example would clarify it?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a note for users, who sometimes take this out of context. I'll clarify.

Comment on lines +29 to +30
C standards
===========
Copy link
Member

Choose a reason for hiding this comment

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

Retain the old anchor:

Suggested change
C standards
===========
.. _c_dialect:
C standards
===========

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants