Algorithm help per favore
David Eppstein
eppstein at ics.uci.edu
Thu Jun 19 11:02:33 EDT 2003
More information about the Python-list mailing list
Thu Jun 19 11:02:33 EDT 2003
- Previous message (by thread): Algorithm help per favore
- Next message (by thread): Algorithm help per favore
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <bcshoh$kb8$1 at news.hccnet.nl>, anton at vredegoor.doge.nl (Anton Vredegoor) wrote: > Output from a test run: > > zipped : 0.985 sec. > ranged : 0.425 sec. > inplace : 0.206 sec. Interesting. When I try it, what I find is that zipped is usually but not always fastest, inplace is a little slower, and ranged is significantly slower -- data at end of message. I tried also a simple generator based one but it didn't do better than the others: def generate(L): return list(generator(L)) def generator(L): last = object() for x in L: if x != last: yield x last = x The test data: % python test.py zipped : 0.090 sec. ranged : 0.190 sec. inplace : 0.090 sec. generate: 0.120 sec. % python test.py zipped : 0.090 sec. ranged : 0.180 sec. inplace : 0.100 sec. generate: 0.110 sec. % python test.py zipped : 0.130 sec. ranged : 0.170 sec. inplace : 0.100 sec. generate: 0.110 sec. % python test.py zipped : 0.070 sec. ranged : 0.150 sec. inplace : 0.110 sec. generate: 0.110 sec. % python test.py zipped : 0.060 sec. ranged : 0.170 sec. inplace : 0.090 sec. generate: 0.090 sec. % python test.py zipped : 0.040 sec. ranged : 0.170 sec. inplace : 0.110 sec. generate: 0.110 sec. % python test.py zipped : 0.040 sec. ranged : 0.150 sec. inplace : 0.100 sec. generate: 0.100 sec. -- David Eppstein http://www.ics.uci.edu/~eppstein/ Univ. of California, Irvine, School of Information & Computer Science
- Previous message (by thread): Algorithm help per favore
- Next message (by thread): Algorithm help per favore
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list