Efficient string concatenation methods

Oliver Crow ocrow at skymind.com
Sun May 2 13:35:00 EDT 2004


Roel Schroeven <rschroev_nospam_ml at fastmail.fm> wrote in message news:<Mc4lc.93415$K%2.5677129 at phobos.telenet-ops.be>...
>
> I'd like to try out another variant, but I'm unable to run your 
> script... Where does that timing module come from? I can't find it anywhere.

It's George Neville-Neil's timing module.  It looks like it used to be
part of the python library, but has been removed in recent versions. 
I'm not sure why.  Perhaps timeit is the new preferred module.

 
> The method I propose is simply
> 
> def method7():
>      return ''.join(map(str, xrange(loop_count)))
> 
> I ran my own little test and it seems to be faster than method6, but I'd 
> like to run it in your script for more reliable results. Also, I haven't 
> done any memory measurement, only a timing.

I'll add that test and rerun the results.

Thanks for the suggestion!

Oliver



More information about the Python-list mailing list