Message270347
| Author |
ztane |
| Recipients |
Demur Rumed, eric.smith, mjpieters, rhettinger, serhiy.storchaka, ztane |
| Date |
2016年07月13日.22:04:03 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1468447443.67.0.472899199293.issue27078@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Thanks Serhiy, I was writing my comment for a long time, and only now noticed that you'd already posted the patch.
Indeed, it seems that not only is this the fastest method, it might also be the fastest string concatenation method in the history of Python. I did some comparison with 8-bit strings in Python 2, doing the equivalent of
f'http://{domain}/{lang}/{path}'
with
domain = 'some_really_long_example.com'
lang = 'en'
path = 'some/really/long/path/'
and the results look quite favourable: 0.151 μs with your patch; 0.250ish for the second fastest method in Python 3.6 (''.join(tuple))
And the fastest method in Python 2 is a tie between concatenating with + or ''.join with bound method reference; both of them take 0.203 μs on Python 2.7 with 8-bit strings and about 0.245 - 0.255 μs if everything is Unicode. |
|