Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename select #22791

Closed
nalimilan opened this issue Jul 13, 2017 · 1 comment · Fixed by #23051
Closed

Rename select #22791

nalimilan opened this issue Jul 13, 2017 · 1 comment · Fixed by #23051

Comments

@nalimilan
Copy link
Member

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.

@Sacha0 Sacha0 mentioned this issue Jul 13, 2017
19 tasks
@andyferris
Copy link
Member

This has bothered me previously.

partialsort seems like an excellent replacement to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants