This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.smith
Recipients eric.smith, poostenr, ubehera
Date 2016-01-15.00:29:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1452817740.24.0.00169044463301.issue26118@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-01-15 00:29:00eric.smithsetrecipients: + eric.smith, poostenr, ubehera
2016-01-15 00:29:00eric.smithsetmessageid: <1452817740.24.0.00169044463301.issue26118@psf.upfronthosting.co.za>
2016-01-15 00:29:00eric.smithlinkissue26118 messages
2016-01-15 00:29:00eric.smithcreate