Selecting k smallest or largest elements from a large list in python; (benchmarking)

Peter Otten __peter__ at
Thu Sep 2 09:18:06 CEST 2010

Dmitry Chichkov wrote:

> Code:

A lot of the following doesn't run or returns incorrect results. 
To give but one example:

> def nargsmallest_numpy_argmin(iter, k):
>     distances = N.asarray(iter)
>     mins = []

Could you please provide an up-to-date version?


PS: for an easy way to ensure consistency see timeit/time_all in my previous 

More information about the Python-list mailing list