flatten a level one list
Cyril Bazin
cyril.bazin at info.unicaen.fr
Fri Jan 13 19:13:09 EST 2006
I added my own function to the benchmark of Robin Becker:
from itertools import chain
def flatten9(x, y):
return list(chain(*izip(x, y)))
Results:
no psyco
Name 10
20 100 200 500 1000
flatten1 104.499 199.699 854.301 1673.102 4084.301
8078.504
flatten2 111.103 204.706 944.901 1778.793 4554.701
8773.494
flatten3 174.594 310.302 1526.308 2880.001 7332.492
12373.209
flatten4 115.204 156.093 467.205 853.705 1920.795
2755.713
flatten5 79.894 117.803 406.504 762.892 1764.297
2663.898
flatten6 136.399 246.596 1142.406 2243.400 5494.809
8625.221
flatten6a 163.889 279.689 1320.195 2691.817 6481.910
9879.899
flatten6b 175.881 275.111 1220.393 2440.596 5955.291
8979.106
flatten6c 160.813 272.989 1138.186 2472.591 5726.314
8415.699
flatten6d 126.004 215.292 988.603 1932.383 4734.492
7447.696
flatten7 37.217 43.297 89.407 134.897 233.006
343.013
flatten8 93.198 190.306 1739.597 4987.907 27208.018
78883.505
flatten8a 112.915 220.299 1875.997 5491.590 28395.319
81628.394
flatten9 98.896 159.812 651.288 1153.994 2980.685
3927.398
Unfortunatly I can't test with psyco for the moment...
Cyril
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060114/7de82465/attachment.html>
More information about the Python-list
mailing list