Message258256
I see a small difference, but I think it's related to the fact that in the first example you're concatenating 2 strings (',' and the result of {0}), and in the 2nd example it's 3 strings ("'", {0}, "',"):
$ echo '",{0}".format(x)'
",{0}".format(x)
$ python -m timeit -s 'x=4' '",{0}".format(x)'
1000000 loops, best of 3: 0.182 usec per loop
$ echo '"'\''{0}'\'',".format(x)'
"'{0}',".format(x)
$ python -m timeit -s 'x=4' '"'\''{0}'\'',".format(x)'
1000000 loops, best of 3: 0.205 usec per loop
If you see a factor of 30x difference in your code, I suspect it's not related to str.format(), but some other processing in your code. |
|
Date |
User |
Action |
Args |
2016-01-15 00:29:00 | eric.smith | set | recipients:
+ eric.smith, poostenr, ubehera |
2016-01-15 00:29:00 | eric.smith | set | messageid: <1452817740.24.0.00169044463301.issue26118@psf.upfronthosting.co.za> |
2016-01-15 00:29:00 | eric.smith | link | issue26118 messages |
2016-01-15 00:29:00 | eric.smith | create | |
|