which is better, string concatentation or substitution?
eurleif at ecritters.biz
Mon May 8 06:35:51 CEST 2006
John Salerno wrote:
> My initial feeling is that concatenation might take longer than
Doesn't look that way:
leif at ubuntu:~$ python -m timeit "'<p>%s</p>\n\n' % 'foobar'"
1000000 loops, best of 3: 0.6 usec per loop
leif at ubuntu:~$ python -m timeit "'<p>' + 'foobar' + '</p>\n\n'"
1000000 loops, best of 3: 0.358 usec per loop
> but that it is also easier to read:
I prefer string formatting for readability, but it's a matter of
More information about the Python-list