Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Take advantage of type uniformity in _bisect.bisect() #96538

Closed
Labels
performancePerformance or resource usagetype-featureA feature request or enhancement
@sweeneyde

Description

@sweeneyde

We can makebisect.bisect(seq, i) get roughly 1.3x faster by taking advantage of type stability, of both the sequence and the keys.

Possible opportunities:

  • All calls toPySequence_GetItem should use the same underlyingtp->tp_as_sequence->sq_item
  • We never call withi < 0, so no need to adjust indices
  • Similar to the strategy employed inlist.sort()'sunsafe_object_compare, we can keep atp_richcompare function pointer around, then check types and use it, with less type-checking. We can always fall back toPyObject_RichCompareBool in case some assumption fails.
  • Recursion checks only need to happen once per bisect call.

Much of this work can be moved outside the loop, so that instead of happeninglg(n) times, it only needs to happened once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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


      [8]ページ先頭

      ©2009-2025 Movatter.jp