Counting number of each item in a list.
bdesth.quelquechose at free.quelquepart.fr
Mon Mar 20 00:26:13 CET 2006
Justin Azoff a écrit :
> Bruno Desthuilliers wrote:
>>And of course, I was right. My solution seems to be faster than Paul's
>>one (but slower than bearophile's), be it on small, medium or large lists.
> Your version is only fast on lists with a very small number of unique
> changing mklist to have
> items = range(64) instead of the 9 item list and re-timing you will get
> "better" results:
> A100 (10000 times): 7.63829684258
> B100 (10000 times): 1.34028482437
> C100 (10000 times): 0.812223911285
> A10000 (100 times): 9.78499102592
> B10000 (100 times): 1.26520299911
> C10000 (100 times): 0.857560873032
> A1000000 (10 times): 87.6713900566
> B1000000 (10 times): 12.7302949429
> C1000000 (10 times): 8.35931396484
So much for my benchmarking skills...
More information about the Python-list