Skip to content

Py_LOCAL_INLINE(type) doesn't actually inline except using MSC #49803

Closed

Description

@stutzbach
mannequin
BPO 5553
Nosy @loewis, @pitrou, @benjaminp, @ned-deily
Files
  • inline.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2010-08-31.19:52:02.631>
    created_at = <Date 2009-03-24.14:49:18.380>
    labels = ['performance']
    title = "Py_LOCAL_INLINE(type) doesn't actually inline except using MSC"
    updated_at = <Date 2010-09-05.04:43:23.365>
    user = 'https://bugs.python.org/stutzbach'

    bugs.python.org fields:

    activity = <Date 2010-09-05.04:43:23.365>
    actor = 'stutzbach'
    assignee = 'stutzbach'
    closed = True
    closed_date = <Date 2010-08-31.19:52:02.631>
    closer = 'stutzbach'
    components = []
    creation = <Date 2009-03-24.14:49:18.380>
    creator = 'stutzbach'
    dependencies = []
    files = ['17149']
    hgrepos = []
    issue_num = 5553
    keywords = ['patch']
    message_count = 9.0
    messages = ['84089', '104470', '104476', '104641', '104644', '105940', '115275', '115621', '115625']
    nosy_count = 6.0
    nosy_names = ['loewis', 'pitrou', 'benjamin.peterson', 'ned.deily', 'stutzbach', 'rpetrov']
    pr_nums = []
    priority = 'low'
    resolution = 'accepted'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue5553'
    versions = ['Python 3.2']

    Activity

    1. stutzbach commented on Mar 24, 2009

      stutzbachmannequin
      MannequinAuthor

      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
    2. self-assigned this
      on Apr 27, 2010
    3. rpetrov commented on Apr 28, 2010

      rpetrovmannequin
      Mannequin

      Configure could call macro to define inline - cf. autoconf manuals.

    4. pitrou commented on Apr 29, 2010

      @pitrou
      Member

      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.

    5. stutzbach commented on Apr 30, 2010

      stutzbachmannequin
      MannequinAuthor

      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.

    6. stutzbach commented on Apr 30, 2010

      stutzbachmannequin
      MannequinAuthor

      I should add that the patch is against the py3k branch, since it's too late for performance improvements to land in trunk.

    7. pitrou commented on May 17, 2010

      @pitrou
      Member

      The patch looks ok to me.

    8. stutzbach commented on Aug 31, 2010

      stutzbachmannequin
      MannequinAuthor

      Committed in r84379

    9. ned-deily commented on Sep 5, 2010

      @ned-deily
      Member

      Note: autoreconf failure caused by r84379 was fixed by r84512.

    10. stutzbach commented on Sep 5, 2010

      stutzbachmannequin
      MannequinAuthor

      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!

    11. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      performancePerformance or resource usage

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions