[Python-Dev] Start writing inlines rather than macros?

Skip Montanaro skip at pobox.com
Thu Feb 27 20:12:24 CET 2014

I think it's at least worthwhile to investigate the use of
inline/static functions over the current macros. It's been many years
since I looked at them. I doubt they have gotten any easier to read or
edit with all their backslashes.

I do have one question though. Suppose you encounter a compiler that
doesn't understand the inline keyword, so you choose the static
declaration as Kristján suggested. The resulting Python executable
should be functionally correct, but if the optimizer doesn't happen to
inline a given static function you might be stuck with some bad
performance across-the-board (if it never inlines, or doesn't inline
where we really need it to), or only under some circumstances (as a
hypothetical example, inlining in dictobject.c, but not in ceval.c).
Is there a configurable way to tell if a compiler will inline
functions which are declared static, and possibly under what
conditions they might not? It might still be necessary to maintain
macros for those platforms.


More information about the Python-Dev mailing list