Julian Taylor added the comment:

for median alone a multiselect is probably overkill (thats why I mentioned the 
minimum trick)

but a selection algorithm is useful on its own for all of python and then a 
multiselect should be considered.
Of course that means it would need to be implemented in C like sorted() so you 
actually have a significant performance gain that makes adding a new python 
function worthwhile.

Also just to save numpys honor, you are benchmarking python list -> numpy array 
conversion and not the actual selection in your script with the numpy 
comparison. The conversion is significantly slower than the selection itself. 
Also select2b is inplace while np.partition is out of place. Repeated inplace 
selection typically gets faster as the number of required swaps goes down and 
can even be constant in time if the requested value does not change.
With that fixed numpy outperforms pypy by about a factor 2 (but pypys 
performance is indeed quite impressive as it is far more generic)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21592>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to