Skip to content

Conversation

@vstinner
Copy link
Member

@vstinnervstinner 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
MemberAuthor

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
MemberAuthor

PR rebased to retrieve the Windows build fix.

Copy link
Contributor

@erlend-aaslanderlend-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?

@vstinnervstinner merged commit 6b41355 into python:mainSep 17, 2021
@vstinnervstinner deleted the add_always_inline branch September 17, 2021 12:09
@vstinner
Copy link
MemberAuthor

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 freeto 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

@vstinner@erlend-aasland@the-knights-who-say-ni@bedevere-bot