Splitting lists
Alex Martelli
aleax at aleax.it
Thu Feb 27 15:39:29 EST 2003
Steven Taschuk wrote:
> Quoth Létezõ:
>> Thanks to Steven for the performance analysis and Alex & Duncan for the
>> their more impressive solutions. It would be interesting to insert the
>> new "impressive" solutions into the performace test loop. Which is the
>> fastest?
>
> Short and long list trials:
>
> viktor1 9.56 9.17
> viktor2 8.60 8.30
> viktor2lookup 6.00 5.72
> viktor3 12.08 14.19
> duncan 8.70 8.49
> duncanlookup 6.04 5.76
> alex 6.47 6.18
Interestingly, my numbers are a bit different:
[alex at lancelot logs]$ python2.3 -O ti.py
viktor1 1.06 1.06
viktor2 0.78 0.77
viktor2lookup 0.66 0.62
viktor3 1.33 1.58
duncan 0.81 0.80
duncanlookup 0.70 0.67
alex 0.71 0.70
[alex at lancelot logs]$
This isn't a particularly hi-end machine -- it's a 1.2 GHz Athlon
PC with DDR 2100 RAM and Linux Mandrake 9.0, reasonably cheap even
when I bought it almost two years ago. This may perhaps indicate
that the best way to speed algorithms up is to purchase halfway
decent hardware no more than a couple of years old, and run a free
operating system &c on it...?-)
Anyway, on my machine "viktor2lookup" -- the simplest approach,
except that the append bound methods are looked up into local
variables just once before the loop -- is repeatably fastest
on this particular test.
Alex
More information about the Python-list
mailing list