Depending whether util.minmax() figures large in the runtime profile, it may be worth optimizing. The faster algorithm is to take two elements at a time from the input sequence. You first compare them to one another, then compare the smaller to the current minimum and the larger to the current maximum, updating the min/max as appropriate. This amortizes to 3 comparison per 2 input elements rather than the current 4 comparisons. However, it's a somewhat more complex algorithm, so it may not be worth the time.
Depending whether
util.minmax()
figures large in the runtime profile, it may be worth optimizing. The faster algorithm is to take two elements at a time from the input sequence. You first compare them to one another, then compare the smaller to the current minimum and the larger to the current maximum, updating the min/max as appropriate. This amortizes to 3 comparison per 2 input elements rather than the current 4 comparisons. However, it's a somewhat more complex algorithm, so it may not be worth the time.