summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/intro.rst
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-09-17 12:09:14 (GMT)
committerGitHub <noreply@github.com>2021-09-17 12:09:14 (GMT)
commit6b413551284a94cfe31377c9c607ff890aa06c26 (patch)
treef113db6c256f4d8565d53b2dbdc6b29019e2d38a /Doc/c-api/intro.rst
parent064464fc38269e70f7e3a34cb25fc9085ab85782 (diff)
downloadcpython-6b413551284a94cfe31377c9c607ff890aa06c26.zip
cpython-6b413551284a94cfe31377c9c607ff890aa06c26.tar.gz
cpython-6b413551284a94cfe31377c9c607ff890aa06c26.tar.bz2
bpo-45116: Add the Py_ALWAYS_INLINE macro (GH-28390)
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.
Diffstat (limited to 'Doc/c-api/intro.rst')
-rw-r--r--Doc/c-api/intro.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst
index 83824bb..aac28b1 100644
--- a/Doc/c-api/intro.rst
+++ b/Doc/c-api/intro.rst
@@ -111,6 +111,25 @@ complete listing.
.. versionadded:: 3.3
+.. c:macro:: Py_ALWAYS_INLINE
+
+ Ask the compiler to always inline a static inline function. The compiler can
+ ignore it and decides to not inline the function.
+
+ It can be used to inline performance critical static inline functions when
+ building Python in debug mode with function inlining disabled. For example,
+ MSC disables function inlining when building in debug mode.
+
+ Marking blindly a static inline function with Py_ALWAYS_INLINE can result in
+ worse performances (due to increased code size for example). The compiler is
+ usually smarter than the developer for the cost/benefit analysis.
+
+ It must be specified before the function return type. Usage::
+
+ static inline Py_ALWAYS_INLINE int random(void) { return 4; }
+
+ .. versionadded:: 3.11
+
.. c:macro:: Py_CHARMASK(c)
Argument must be a character or an integer in the range [-128, 127] or [0,