In python, which one is faster ?
numpy.max(), numpy.min()
or
max(), min()
My list/array length varies from 2 to 600. Which one should I use to save some run time ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well from my timings it follows if you already have numpy array
ayou should usea.max(the source tells it’s the same asnp.maxifa.maxavailable). But if you have built-in list then most of the time takes converting it into np.ndarray => that’s whymaxis better in your timings.In essense: if
np.ndarraythena.max, iflistand no need for all the machinery ofnp.ndarraythen standardmax.