Message270347
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. |
|
Date |
User |
Action |
Args |
2016-07-13 22:04:03 | ztane | set | recipients:
+ ztane, rhettinger, mjpieters, eric.smith, serhiy.storchaka, Demur Rumed |
2016-07-13 22:04:03 | ztane | set | messageid: <1468447443.67.0.472899199293.issue27078@psf.upfronthosting.co.za> |
2016-07-13 22:04:03 | ztane | link | issue27078 messages |
2016-07-13 22:04:03 | ztane | create | |
|