Re: Fastest way to max() list

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gabriel Genellina

    #1

    Re: Fastest way to max() list

    En Fri, 26 Sep 2008 01:42:59 -0300, Chris Rebert <clp@rebertia.c om>
    escribió:
    B. Assuming by "distance" you meant "difference " and/or that the
    distance is only in 1 dimension:
    >
    from operator import itemgetter
    firsts = map(itemgetter( 0), main_list)
    distance = max(firsts) - min(firsts)
    I think the above expression is overcomplicated . The code below does the
    exact same thing and is easier to understand, IMHO:

    firsts = [item[0] for item in main_list]
    distance = max(firsts) - min(firsts)

    --
    Gabriel Genellina

Working...