File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,9 @@ complete listing.
124
124
worse performances (due to increased code size for example). The compiler is
125
125
usually smarter than the developer for the cost/benefit analysis.
126
126
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
+
127
130
It must be specified before the function return type. Usage::
128
131
129
132
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" {
568
568
// worse performances (due to increased code size for example). The compiler is
569
569
// usually smarter than the developer for the cost/benefit analysis.
570
570
//
571
+ // If Python is built in debug mode (if the Py_DEBUG macro is defined), the
572
+ // Py_ALWAYS_INLINE macro does nothing.
573
+ //
571
574
// It must be specified before the function return type. Usage:
572
575
//
573
576
// 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 )
575
584
# define Py_ALWAYS_INLINE __attribute__((always_inline))
576
585
#elif defined(_MSC_VER )
577
586
# define Py_ALWAYS_INLINE __forceinline
You can’t perform that action at this time.
0 commit comments