List problem

Alex Martelli aleaxit at yahoo.com
Mon Nov 1 02:46:09 EST 2004


Bengt Richter <bokr at oz.net> wrote:
   ...
> >def delsome_am(n=1000000, todel=[2]):
> >    a = range(n)
> >    a = [x for x in a if x not in todel]
>      ^-- shud be a[:] ;-)
> (I think the missing return a is in the noise ;-)

Right, sorry.

> >kallisti:/tmp alex$ python -mtimeit -s'import br' 'br.delsome_br()'
> >10 loops, best of 3: 4.44 sec per loop
> >kallisti:/tmp alex$ python -mtimeit -s'import br' 'br.delsome_am()'
> >10 loops, best of 3: 3.92 sec per loop
> >
> I thought you had 'way faster machines than mine. Neither time is an
> improvement over delsome_br for 2.3.2 on my old box. I wonder what's up.

I ran these on an 800 MHz laptop, the one I invariably use for netting
-- best ergonomics.  OK, I'll try with faster machines when I get a
chance -- I'm surprised you measure almost a 1:2 ratio with _br faster.


Alex



More information about the Python-list mailing list