GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Consider enabling tail call interpreter for `sre_lib.h` · Issue #161469 · python/cpython

Consider enabling tail call interpreter for sre_lib.h #161469

New issue
Copy link
New issue
Copy link
Open
Open
Consider enabling tail call interpreter for sre_lib.h#161469
Copy link
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirperformancePerformance or resource usagePerformance or resource usagetopic-regextype-featureA feature request or enhancementA feature request or enhancement

Description

@sobolevn
sobolevn
opened on Nov 6, 2026
Issue body actions

It already supports computed gotos:

cpython/Modules/_sre/sre_lib.h

Lines 636 to 657 in 4b50f88

#ifdef HAVE_COMPUTED_GOTOS
#ifndef USE_COMPUTED_GOTOS
#define USE_COMPUTED_GOTOS 1
#endif
#elif defined(USE_COMPUTED_GOTOS) && USE_COMPUTED_GOTOS
#error "Computed gotos are not supported on this compiler."
#else
#undef USE_COMPUTED_GOTOS
#define USE_COMPUTED_GOTOS 0
#endif
#if USE_COMPUTED_GOTOS
#define TARGET(OP) TARGET_ ## OP
#define DISPATCH \
do { \
MAYBE_CHECK_SIGNALS; \
goto *sre_targets[*pattern++]; \
} while (0)
#else
#define TARGET(OP) case OP
#define DISPATCH goto dispatch
#endif

Maybe adding tail-calling interpreter will give meaningful speed up for all re calls as well? This might speed up a lot of places in the real code almost for free.

This needs to be researched and measured before making a PR.

Activity

  1. sobolevn
    added
    type-featureA feature request or enhancementA feature request or enhancement
    performancePerformance or resource usagePerformance or resource usage
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    topic-regex
    on Nov 6, 2026
  2. sobolevn commented on Nov 6, 2026

    @sobolevn
    sobolevn
    on Nov 6, 2026
    MemberAuthor
    More actions

    CC @Fidget-Spinner, maybe you have an opinion on this :)

  3. Fidget-Spinner commented on Nov 6, 2026

    @Fidget-Spinner
    Fidget-Spinner
    on Nov 6, 2026
    Member
    More actions

    I think I looked at the sre interpreter some time ago and concluded at the time to support things it would be pretty invasive, as some of it has jump targets within labels, and that kind of unstructured control-flow is unsupported by the tailcalling approach. At the very minimum, a refactor of the sre interpreter might be required. I might be remembering wrong and/or thinking of the marshal interpreter though. Anyways, with an AI agent it's probably much easier to do nowdays.

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

    extension-modulesC modules in the Modules dirC modules in the Modules dirperformancePerformance or resource usagePerformance or resource usagetopic-regextype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.