17th December 2008, 3 min read Fast argmax in Python 5 thoughts on “Fast argmax in Python” bartkiller says: February 13, 2011 at 2:55 pm Complexity of these operations with regard to array length would be more interesting. I think that your conclusion is a bit too wide. Daniel Lemire says: April 3, 2019 at 7:35 pm They all have linear complexity. bbq says: April 19, 2012 at 9:09 am Interesting! The first solution is amazing! staniec says: November 28, 2016 at 4:17 pm What about: max(range(len(array)), key=lambda x: array[x]) GS says: April 3, 2019 at 1:46 pm Slower than a.index(max(a)). (Tested by ipython %timeit)
Complexity of these operations with regard to array length would be more interesting. I think that your conclusion is a bit too wide.
They all have linear complexity.
Interesting!
The first solution is amazing!
What about:
max(range(len(array)), key=lambda x: array[x])
Slower than
a.index(max(a))
. (Tested by ipython%timeit
)