Skip to content
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

bpo-45116: Add the Py_ALWAYS_INLINE macro #28390

Merged
merged 3 commits into from
Sep 17, 2021
Merged

bpo-45116: Add the Py_ALWAYS_INLINE macro #28390

merged 3 commits into from
Sep 17, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Sep 16, 2021

Add the Py_ALWAYS_INLINE macro to ask the compiler to always inline a
static inline function. The compiler can ignore it and decides to not
inline the function.

https://bugs.python.org/issue45116

@vstinner
Copy link
Member Author

I decided to split my old PR #28141 in two parts:

  • (1) this PR adds the macro
  • (2) use the macro on some performance critical static inline functions

Add the Py_ALWAYS_INLINE macro to ask the compiler to always inline a
static inline function. The compiler can ignore it and decides to not
inline the function.
@vstinner
Copy link
Member Author

PR rebased to retrieve the Windows build fix.

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

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

How about a What's New entry?

@vstinner vstinner merged commit 6b41355 into python:main Sep 17, 2021
@vstinner vstinner deleted the add_always_inline branch September 17, 2021 12:09
@vstinner
Copy link
Member Author

How about a What's New entry?

I don't want to advertise too much this macro :-D As I wrote in its documentation, misusing it can make the code slower.

Also, I'm not even sure if it should be used in Python :-) Benchmarks will give us some hints ;-)

niyas-sait pushed a commit to niyas-sait/cpython that referenced this pull request Sep 21, 2021
Add the Py_ALWAYS_INLINE macro to ask the compiler to always inline a
static inline function. The compiler can ignore it and decides to not
inline the function.
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.

4 participants