File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,9 @@ complete listing.
124124 worse performances (due to increased code size for example). The compiler is
125125 usually smarter than the developer for the cost/benefit analysis.
126126
127+ If Python is :ref: `built in debug mode <debug-build >` (if the ``Py_DEBUG ``
128+ macro is defined), the :c:macro: `Py_ALWAYS_INLINE ` macro does nothing.
129+
127130 It must be specified before the function return type. Usage::
128131
129132 static inline Py_ALWAYS_INLINE int random(void) { return 4; }
Original file line number Diff line number Diff line change @@ -568,10 +568,19 @@ extern "C" {
568568// worse performances (due to increased code size for example). The compiler is
569569// usually smarter than the developer for the cost/benefit analysis.
570570//
571+ // If Python is built in debug mode (if the Py_DEBUG macro is defined), the
572+ // Py_ALWAYS_INLINE macro does nothing.
573+ //
571574// It must be specified before the function return type. Usage:
572575//
573576// static inline Py_ALWAYS_INLINE int random(void) { return 4; }
574- #if defined(__GNUC__ ) || defined(__clang__ ) || defined(__INTEL_COMPILER )
577+ #if defined(Py_DEBUG )
578+ // If Python is built in debug mode, usually compiler optimizations are
579+ // disabled. In this case, Py_ALWAYS_INLINE can increase a lot the stack
580+ // memory usage. For example, forcing inlining using gcc -O0 increases the
581+ // stack usage from 6 KB to 15 KB per Python function call.
582+ # define Py_ALWAYS_INLINE
583+ #elif defined(__GNUC__ ) || defined(__clang__ ) || defined(__INTEL_COMPILER )
575584# define Py_ALWAYS_INLINE __attribute__((always_inline))
576585#elif defined(_MSC_VER )
577586# define Py_ALWAYS_INLINE __forceinline
You can’t perform that action at this time.
0 commit comments