Skip to content

Widen specialized int fast paths to full int64 range #150424

Description

@KRRT7

This work widens the interpreter’s specialized int fast paths (tier-2 / uop execution) from the compact-only range to the full int64_t range.

It also fixes follow-up correctness issues in the widened specialized paths for non-compact exact PyLongObjects and on 15-bit builds.

Scope:

  • widen specialized integer add/subtract/multiply fast paths to operate across the full int64_t range
  • accept exact int operands that fit in int64_t, including non-compact PyLongObjects
  • keep specialized in-place mutation compact-only and fall back safely for non-compact inputs
  • handle widened integer compare without compact-only assumptions
  • construct widened arithmetic results with PyLong_FromInt64() so 15-bit builds do not narrow through stwodigits
  • add regression coverage for widened operations, non-compact exact ints, boundary cases, and overflow fallback
  • add benchmark scripts for measuring widened specialized integer fast-path performance

Linked PRs

Activity

  1. changed the title [-]Specialized widened JIT int paths still assume compact PyLongs[/-] [+]Widen JIT int fast paths to full int64 range[/+] on May 25, 2026
  2. picnixz commented on May 25, 2026

    @picnixz
    Member

    Do we support 15-bit builds actually?

  3. added
    pendingThe issue will be closed if no feedback is provided
    on May 25, 2026
  4. picnixz commented on May 25, 2026

    @picnixz
    Member

    In addition, please clearly clarify the issue. The issue description is obscure and looks like a simple LLM report. In particular, please read https://devguide.python.org/getting-started/generative-ai/ first and share benchmarks if they improve.

  5. markshannon commented on May 26, 2026

    @markshannon
    Member

    If you want to improve int performance then take a look at #101291

  6. locked and limited conversation to collaborators on May 27, 2026
  7. unlocked this conversation on May 27, 2026
  8. KRRT7 commented on May 28, 2026

    @KRRT7
    Author

    @markshannon Thanks! I had looked for something like that issue but hadn't found it for whatever reason, probably because cpython has so many issues.

    the work I'm doing #150425, is based off of work already being done in another project I'm involved in, as I had tried to explain (and show) in that other PR, gh-150424 was a draft and still a WIP so what was being seen, was not the completed version.

    right now it's in a much better state and has benchmarks, I've had some guidance from @Fidget-Spinner whilst working on this and plan to do some more benchmarking and correctness testing locally before reopening.

  9. KRRT7 commented on May 28, 2026

    @KRRT7
    Author

    In particular, please read https://devguide.python.org/getting-started/generative-ai/

    I believe I had in the PR already stated that I did read that.

    The issue description is obscure and looks like a simple LLM report.

    None of the templates have anything for performance related "issues" that I felt I could open up with.
    https://github.com/python/cpython/tree/main/.github/ISSUE_TEMPLATE/

    in the absence of that, a simple, straightforward body was what I felt best. and I've edited It multiple times as I kept seeing room for improvement.

  10. KRRT7 commented on May 28, 2026

    @KRRT7
    Author

    I just did a deep search thru issues and PRs and i found these prior arts where i feel that my current work builds on top off of:

  11. Fidget-Spinner commented on May 28, 2026

    @Fidget-Spinner
    Member

    @markshannon I think changing the int layout is potentially more disruptive to the C API. This change purportedly introduces a speedup without any layout changes. So we should consider it as-is.

  12. KRRT7 commented on May 28, 2026

    @KRRT7
    Author

    After a short conversation with @Fidget-Spinner , I’ve updated the wording here (and in the linked PR) to avoid calling this “the JIT”.

    I had been mentally grouping the specializing interpreter / tier-2 uop machinery under “JIT”, but the change itself is to the
    interpreter’s specialized execution paths

  13. changed the title [-]Widen JIT int fast paths to full int64 range[/-] [+]Widen specialized int fast paths to full int64 range[/+] on May 28, 2026
  14. added
    type-featureA feature request or enhancement
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    and removed
    pendingThe issue will be closed if no feedback is provided
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    on May 28, 2026
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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagetype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions