[Numpy-discussion] quickselect via np.partition available in 1.8.dev
Mon Aug 12 09:23:34 CDT 2013
a selection algorithm  has now landed in the numpy development branch
The function exposing it is:
numpy.partition(data, kth=int/array, axis=-1, kind="introselect",
Please see the docstrings on what it actually does (and report if they
Thanks to the numpy developers for the review and thanks to all who
If you have a program which might benefit from using selection instead
of sorting please try it out and report if you are happy with its result
and the api.
As first function in numpy median has been converted to use partition so
it now scales linear with the datasize instead of linearithmic. You can
probably expect a five times speedup for array sizes around 1e6.
But this also involves a slight change in behavior for the case where
you use overwrite_input=True
In the past this sorted the full array, now it will only be partially
sorted. That the array is sorted was always documented as an
implementation detail so hopefully that won't break any code.
The next function to be adapted will most likely be numpy.percentile.
More information about the NumPy-Discussion