[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Function to determine list max without itertools

On 4/19/19 5:34 PM, MRAB wrote:

> How would you avoid comparing the initial max with list[0]? By slicing 
> the list? By using 'iter' and 'next'? Do you expect that doing either of 
> those to avoid a single comparison would make it faster? Is a comparison 
> very expensive?
> You could, of course, do some benchmarks to see if it makes a 
> difference, but, personally, I'd just leave it.

Personally yes, but because it allows it to execute on non-sequence 
iterables rather than because it saves a single near-instantaneous 

Rob Gaddi, Highland Technology --
Email address domain is currently out of order.  See above to fix.