argmax

Duncan Booth duncan.booth at invalid.invalid
Thu Jun 1 17:29:21 CEST 2006


David Isaac wrote:

> 1. Why is there no argmax built-in?
> (This would return the index of the largest element in a sequence.)

Probably there isn't a built-in because it isn't a commonly needed 
function.

What is your use-case for argmax? If for example you want to repeatedly 
remove the largest element from a list, then sort the list and pop the last 
element (or use a heap, except heapq lets you pop the smallest so you can't 
use it directly).



More information about the Python-list mailing list