Function to determine list max without itertools

Rob Gaddi rgaddi at highlandtechnology.invalid
Fri Apr 19 20:37:03 EDT 2019


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

[snip]
> 
> 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 
comparison.


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



More information about the Python-list mailing list