Sion Arrowsmith wrote: > But note that a significant chunk is the join(): > > $ python2.4 -mtimeit '"".join(reversed("foo"))' > 100000 loops, best of 3: 2.72 usec per loop > $ python2.4 -mtimeit 'reversed("foo")' > 1000000 loops, best of 3: 1.69 usec per loop
your second benchmark doesn't do any reversal, though. it only creates a bunch of reversed() iterator objects. it's a little like my old faster-than-the-speed-of-light XML parser benchmark: > dir test.xml ... 2005-05-04 20:41 12 658 399 test.xml ... > python -m timeit -s "import cElementTree" "matches = (elem.get('value') for event, elem in cElementTree.iterparse('test.xml') if elem.get('name') == 'reselectApi')" 1000 loops, best of 3: 198 usec per loop > python -c "print 12658399 / 198e-6" 63931308080.8 (64 gigabytes per second? who said XML was a performance hog ?) </F> -- http://mail.python.org/mailman/listinfo/python-list