Skip to content

gh-117549: Don't use designated initializers in headers #118580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 5, 2024

Conversation

gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented May 4, 2024

Apparently in C++ this requires a recent standard version (C++20) and not everyone can switch to that yet. And this header, while internal, is included (possibly indirectly, via pycore_code.h) by some key 3rd party software that does so for speed, and we don't want to require folks to upgrade their C++ standard version when upgrading to Python 3.13.

NOTE: Before merging this I want to double-check that it doesn't slow things down. I'll start a benchmark run on our internal benchmark infrastructure.

Copy link
Contributor

@scoder scoder left a comment

Choose a reason for hiding this comment

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

The change looks reasonable to me and should resolve the issue. I couldn't test it because so far I found the problem only with MSVC and I don't have MSVC to test locally. Compiling CPython main with this patch on Linux with g++ and testing it there worked ok for me. Regarding performance, any C/C++ compiler that fails to alias the inlined function call and its return value into a plain value here should blush and rub its face in dirt.

@scoder
Copy link
Contributor

scoder commented May 4, 2024

Thanks for the quick response, I appreciate it.

@gvanrossum
Copy link
Member Author

Benchmarks show nothing unexpected. I'll merge now.

@gvanrossum gvanrossum enabled auto-merge (squash) May 5, 2024 19:11
@gvanrossum gvanrossum merged commit 40cc809 into python:main May 5, 2024
36 checks passed
@gvanrossum gvanrossum deleted the backoff-counter-woes branch May 5, 2024 21:01
SonicField pushed a commit to SonicField/cpython that referenced this pull request May 8, 2024
…#118580)

The designated initializer syntax in static inline functions in pycore_backoff.h
causes problems for C++ or MSVC users who aren't yet using C++20.
While internal, pycore_backoff.h is included (indirectly, via pycore_code.h)
by some key 3rd party software that does so for speed.
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.

2 participants