which is better, string concatentation or substitution?
Leif K-Brooks
eurleif at ecritters.biz
Mon May 8 02:55:33 EDT 2006
fuzzylollipop wrote:
> niether .join() is the fastest
Please quote what you're replying to.
No, it's the slowest:
leif at ubuntu:~$ python -m timeit "'<p>%s</p>\n\n' % 'foobar'"
1000000 loops, best of 3: 0.607 usec per loop
leif at ubuntu:~$ python -m timeit "'<p>' + 'foobar' + '</p>\n\n'"
1000000 loops, best of 3: 0.38 usec per loop
leif at ubuntu:~$ python -m timeit "''.join(['<p>', 'foobar', '</p>\n\n'])"
1000000 loops, best of 3: 0.817 usec per loop
More information about the Python-list
mailing list