George Sakkis wrote:
Another alternative is:
from operator import itemgetter
def m3():
colours, nums = zip(*map(itemgetter('colour','num'), l))
It's slower than m1() but faster than m2(); it's also the most
concise, especially if you extract more than two keys.
Good you guys gave me som
On May 2, 2:17 am, Matimus <[EMAIL PROTECTED]> wrote:
> On May 1, 10:50 pm, George Sakkis <[EMAIL PROTECTED]> wrote:
>
>
>
> > On May 1, 11:46 pm, Carsten Haese <[EMAIL PROTECTED]> wrote:
>
> > > Yves Dorfsman wrote:
>
> > > > In the following script, m1() and m2() work fine. I am assuming m2() is
On May 1, 10:50 pm, George Sakkis <[EMAIL PROTECTED]> wrote:
> On May 1, 11:46 pm, Carsten Haese <[EMAIL PROTECTED]> wrote:
>
>
>
> > Yves Dorfsman wrote:
>
> > > In the following script, m1() and m2() work fine. I am assuming m2() is
> > > faster although I haven't checked that (loops through the
On May 1, 11:46 pm, Carsten Haese <[EMAIL PROTECTED]> wrote:
> Yves Dorfsman wrote:
>
> > In the following script, m1() and m2() work fine. I am assuming m2() is
> > faster although I haven't checked that (loops through the list twice
> > instead of once).
>
> Well, let's check it:
>
> $ python -m
On May 1, 8:01 pm, Yves Dorfsman <[EMAIL PROTECTED]> wrote:
> In the following script, m1() and m2() work fine. I am assuming m2() is
> faster although I haven't checked that (loops through the list twice instead
> of once).
>
> Now what I am trying to do is something like m3(). As currently writte
Yves Dorfsman wrote:
In the following script, m1() and m2() work fine. I am assuming m2() is
faster although I haven't checked that (loops through the list twice
instead of once).
Well, let's check it:
$ python -m timeit -s "import x" "x.m1()"
10 loops, best of 3: 6.43 usec per loop
$
In the following script, m1() and m2() work fine. I am assuming m2() is
faster although I haven't checked that (loops through the list twice instead
of once).
Now what I am trying to do is something like m3(). As currently written it
does not work, and I have tried different ways, but I have