Antti Haapala added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27078>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com