Efficient string concatenation methods

Gyoung-Yoon Noh nohmad at sub-port.net
Sun May 2 14:37:23 EDT 2004


Roel Schroeven <rschroev_nospam_ml at fastmail.fm> wrote in message news:<Mc4lc.93415$K%2.5677129 at phobos.telenet-ops.be>...
> def method7():
>      return ''.join(map(str, xrange(loop_count)))

repr is faster than str. Below is my result. 'method8' is only
replacement of 'str' in 'method7' to 'repr'.

[snip]
$ python strcat.py
method 6 : 1.474309
process: 1 kb

method 7 : 1.415451
process: 1 kb

method 8 : 1.221584
process: 1 kb



More information about the Python-list mailing list