Skip to content

Rewrite binarysort() #116939

@tim-one

Description

@tim-one

Feature or enhancement

Proposal:

I tried many things to speed listobject.c's binarysort(), but nothing really helped (neither code tweaks nor entirely different approaches).

However, I got annoyed enough at the ancient code to rewrite it 😉 Some specific annoyances:

  • When sortslices were introduced, this was left with a slightly weird signature, mixing a semi-abstract sortslice argument with raw pointers into the key part.

  • My aging eyes can often no longer see the difference between "l" and "1".

  • While it's still idiomatic C to do pointer arithmetic "by hand", the code is clearer when written in a[index] style. At least for simple code like this, modern optimizing compilers should produce much the same machine instructions either way.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

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