Issue 5553: Py_LOCAL_INLINE(type) doesn't actually inline except using MSC
Created on 2009-03-24 14:49 by stutzbach, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| inline.patch | stutzbach, 2010-04-30 15:00 | |||
| Messages (9) | |||
|---|---|---|---|
| msg84089 - (view) | Author: Daniel Stutzbach (stutzbach) ![]() |
Date: 2009-03-24 14:49 | |
Below is the relevant snippet from pyport.h. There are two reasons that
Py_LOCAL_INLINE doesn't actually emit the "inline" keyword (unless
compiling with MSC).
First, "configure" does not have code to test the compiler and define
USE_INLINE if appropriate.
Second, the code undefines USE_INLINE even if defined! (oops? ;) )
The snippet is replicated with slightly different names near the top of
_sre.c.
#undef USE_INLINE /* XXX - set via configure? */
#if defined(_MSC_VER)
#if defined(PY_LOCAL_AGGRESSIVE)
/* enable more aggressive optimization for visual studio */
#pragma optimize("agtw", on)
#endif
/* ignore warnings if the compiler decides not to inline a function */
#pragma warning(disable: 4710)
/* fastest possible local call under MSVC */
#define Py_LOCAL(type) static type __fastcall
#define Py_LOCAL_INLINE(type) static __inline type __fastcall
#elif defined(USE_INLINE)
#define Py_LOCAL(type) static type
#define Py_LOCAL_INLINE(type) static inline type
#else
#define Py_LOCAL(type) static type
#define Py_LOCAL_INLINE(type) static type
#endif
|
|||
| msg104470 - (view) | Author: Roumen Petrov (rpetrov) * | Date: 2010-04-28 21:57 | |
Configure could call macro to define inline - cf. autoconf manuals. |
|||
| msg104476 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2010-04-29 00:01 | |
Py_LOCAL_INLINE is also not used a lot. Usually, the compiler will inline small static functions by itself. Most of the time, we used #defines rather than functions when we want to inline short snippets of code. |
|||
| msg104641 - (view) | Author: Daniel Stutzbach (stutzbach) ![]() |
Date: 2010-04-30 15:00 | |
Attached is a patch. The diff to configure is just what autoconf produces as a result of the diff to configure.in. With the patch, pyconfig.h will: - do nothing if the compiler supports the "inline" keyword - #define inline to __inline or __inline__ if that's the compiler supports - #define inline to nothing if the compiler doesn't support inlining The patch also updates pyport.h and _sre.c appropriately. |
|||
| msg104644 - (view) | Author: Daniel Stutzbach (stutzbach) ![]() |
Date: 2010-04-30 15:06 | |
I should add that the patch is against the py3k branch, since it's too late for performance improvements to land in trunk. |
|||
| msg105940 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2010-05-17 21:38 | |
The patch looks ok to me. |
|||
| msg115275 - (view) | Author: Daniel Stutzbach (stutzbach) ![]() |
Date: 2010-08-31 19:52 | |
Committed in r84379 |
|||
| msg115621 - (view) | Author: Ned Deily (ned.deily) * ![]() |
Date: 2010-09-05 00:34 | |
Note: autoreconf failure caused by r84379 was fixed by r84512. |
|||
| msg115625 - (view) | Author: Daniel Stutzbach (stutzbach) ![]() |
Date: 2010-09-05 04:43 | |
Ned, thanks for bringing that to my attention. I might have missed it otherwise. I had run "autoconf" but had not known to run "autoreconf", so I had missed the failure there. *embarrassed* Benjamin, thanks for fixing my error! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:46 | admin | set | github: 49803 |
| 2010-09-05 04:43:23 | stutzbach | set | nosy:
+ benjamin.peterson messages: + msg115625 |
| 2010-09-05 00:34:40 | ned.deily | set | nosy:
+ ned.deily messages: + msg115621 |
| 2010-08-31 19:52:02 | stutzbach | set | status: open -> closed messages: + msg115275 keywords:
- needs review |
| 2010-05-17 21:38:31 | pitrou | set | nosy:
+ loewis messages: + msg105940 |
| 2010-04-30 15:06:35 | stutzbach | set | messages: + msg104644 |
| 2010-04-30 15:00:07 | stutzbach | set | keywords:
+ patch, needs review files: + inline.patch messages: + msg104641 stage: needs patch -> patch review |
| 2010-04-29 00:01:44 | pitrou | set | nosy:
+ pitrou messages: + msg104476 |
| 2010-04-28 21:57:32 | rpetrov | set | nosy:
+ rpetrov messages: + msg104470 |
| 2010-04-27 15:28:13 | stutzbach | set | priority: low assignee: stutzbach stage: needs patch type: performance versions: + Python 3.2, - Python 3.0, Python 3.1, Python 2.7 |
| 2009-03-24 14:49:18 | stutzbach | create | |
