News for hackers. Stuff that matters.
Re:How I Got a 2x Speedup With One Line of Code by temujin on Thursday November 14, 2013 @07:24PM (#6736850)
Er, are you aware of the C++ standard library's std::nth_element() function? (Even my "pure C" programs tend to be compiled with g++ to gain access to that and std::sort().)
Re:How I Got a 2x Speedup With One Line of Code by nly on Thursday November 14, 2013 @09:12PM (#6737259)
Yes, this is exactly what the author is trying to port to Python.

Mandatory reference link: http://en.cppreference.com/w/cpp/algorithm/nth_element . Note linear complexity.

There's also std::partial_sort:

http://en.cppreference.com/w/cpp/algorithm/partial_sort