Skip to content

bpo-45094: Add Py_ALWAYS_INLINE macro - #28141

Closed
vstinner wants to merge 2 commits into
python:mainfrom
vstinner:always_inline
Closed

vstinner wants to merge 2 commits into
python:mainfrom
vstinner:always_inline

Conversation

@vstinner

@vstinner vstinner commented Sep 3, 2021 •

Copy link
Copy Markdown
Member

Add Py_ALWAYS_INLINE macro to ask the compiler to always inline a
static inline function.

Use Py_ALWAYS_INLINE on static inline functions:

  • Py_DECREF(), Py_XDECREF()
  • Py_INCREF(), Py_XINCREF()
  • Py_IS_TYPE()
  • Py_NewRef(), Py_XNewRef()
  • Py_REFCNT()
  • Py_SET_REFCNT(), Py_SET_SIZE(), Py_SET_TYPE()

https://bugs.python.org/issue45094

Add Py_ALWAYS_INLINE macro to ask the compiler to always inline a
static inline function.

Use Py_ALWAYS_INLINE on static inline functions:

* Py_DECREF(), Py_XDECREF()
* Py_INCREF(), Py_XINCREF()
* Py_IS_TYPE()
* Py_NewRef(), Py_XNewRef()
* Py_REFCNT()
* Py_SET_REFCNT(), Py_SET_SIZE(), Py_SET_TYPE()
@vstinner

vstinner commented Sep 3, 2021

Copy link
Copy Markdown
Member Author

@Fidget-Spinner Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I just have some minor nits with wording and usage.

Comment thread Doc/c-api/intro.rst Resolved
Comment thread Include/object.h Resolved
Comment thread Include/pyport.h Outdated
#endif

// Ask the compiler to always inline a static inline function. The compiler is
// free is ignored this "hint". This attribute can be used to avoid increasing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// free is ignored this "hint". This attribute can be used to avoid increasing
// free to ignore this "hint". This attribute can be used to avoid increasing
Comment thread Include/object.h Resolved

@erlend-aasland erlend-aasland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have nothing to add after Ken's comments. LGTM :)

@vstinner

vstinner commented Sep 4, 2021

Copy link
Copy Markdown
Member Author

Sadly, it doesn't seem to solve PR #28128 problem.

@vstinner
vstinner marked this pull request as draft September 4, 2021 01:15
@vstinner

vstinner commented Sep 7, 2021

Copy link
Copy Markdown
Member Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

5 participants