[Python-Dev] Start writing inlines rather than macros?
solipsis at pitrou.net
Thu Feb 27 20:23:02 CET 2014
On Thu, 27 Feb 2014 13:12:24 -0600
Skip Montanaro <skip at pobox.com> wrote:
> 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 can assure you they haven't :-)
> 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
You're right. Since we only define macros where performance is critical
(such as INCREF and DECREF), it would definitely have a very
significant impact on performance.
> 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.
Well, if we must maintain macros, let's maintain them everywhere and
avoid the burden of two different implementations for the same thing.
More information about the Python-Dev