Proposal: min(None, x) and max(None, x) return x

Chad Netzer cnetzer at mail.arc.nasa.gov
Fri Nov 22 19:35:22 EST 2002


On Friday 22 November 2002 16:19, Skip Montanaro wrote:

> Wouldn't it be better to accumulate all your x's in a list and call max
> once at the end:
>
>     xlist = []
>     for -whatever-:
>         xlist.append(big_hairy_calc)
>     xMax = max(xlist)

The original posted code (by Eric Brunel) seemed to indicate that the current 
xMax value might be needed in the loop (a "running max").  If that is not a 
requirement, then your method works quite well (for tractable list sizes).

-- 
Bay Area Python Interest Group - http://www.baypiggies.net/

Chad Netzer
cnetzer at mail.arc.nasa.gov




More information about the Python-list mailing list