Skip to content

Rename select #22791

Closed
Closed

Description

select is a very overloaded term, with common meanings in databases (inspired from SQL) and Unix I/O APIs. The fact that Base defined a function with that name is annoying for query packages: both Query.jl and DataFramesMeta.jl define a @select macro, and the latter currently defines a select function (with type piracy issues, cf. JuliaData/DataFramesMeta.jl#75).

On top of this, select does not appear to be a standard name at all for what this function does, i.e. partial sorting a.k.a. selection algorithm. Very few languages seem to provide such a function in their standard library, and none uses this name. The closest example I could find is the C++ stdlib, which provides partial_sort and nth_element (the latter being equivalent to our select when passed a single index). Perl's Sort::Key::Top module provides topsort and atpos, respectively. Python provides heapq.nlargest/heapq.nsmallest, but no equivalent of nth_element/atpos. C++, MATLAB, Ruby, Rust and Go do not support this AFAICT.

I suggest renaming select to partial_sort or partialsort. It appears to be the most common name used on forums (in particular since the C++ stdlib is the only major implementation around), it's similar to sort, it's more explicit and thus easier to find and it does not conflict with other uses.

For reference, select was added in 51d055d and integrated to Base in 561bcc3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions