Skip to content

Missing fast path in PyLong_From*() functions for compact integers #129149

Description

@chris-eibl

Feature or enhancement

Proposal:

See e.g. the fast path using_PyLong_FromMedium() in PyLong_FromLong(). PyLong_FromLongLong() is almost identical.

Maybe then implement PyLong_FromSsize_t(), PyLong_FromLong() and PyLong_FromLongLong()) using a macro similar to PYLONG_FROM_UINT to get rid of the repetitive code?

PYLONG_FROM_UINT is missing the fast path for medium values, too.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

Per encouragement from @iritkatriel in #128927 (comment)

Linked PRs

Activity

  1. changed the title [-]PyLong_FromSsize_t(), PyLong_FromUnsignedLong(), PyLong_FromUnsignedLong() and PyLong_FromSize_t() miss the fast path for compact integers[/-] [+]Missing fast path in PyLong_From*() functions for compact integers[/+] on Jan 21, 2025
  2. chris-eibl commented on Jan 21, 2025

    @chris-eibl
    MemberAuthor

    PyLong_FromInt32(), PyLong_FromUInt32(), PyLong_FromInt64 and PyLong_FromUInt64() could maybe use these macros, too.
    They do "the same thing" in a totally different way ...
    PR is here #131211, and would also give us some nicely speed ups.

  3. added a commit that references this issue on Jan 23, 2025
  4. added a commit that references this issue on Jan 25, 2025
  5. added a commit that references this issue on Mar 13, 2025
  6. added a commit that references this issue on Mar 17, 2025
  7. added a commit that references this issue on Mar 30, 2025
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