faster way for adding many strings

Syver Enstad syver-en+usenet at online.no
Tue Sep 17 08:48:38 EDT 2002


Peter Hansen <peter at engcorp.com> writes:

> Ulli Stein wrote:
> > Hi,
> > What is the faster way: appending many strings to a list and then
> > joining them, or writing to StringIO and then getvalue()?
> 
> Alex' detailed response notwithstanding, there's another usual
> answer to your question:
> 
> "Premature optimization is the root of all evil in programming"
> (D. Knuth)
> 
> It means you usually shouldn't care which is faster until (a) your
> software is working fully, and (b) you have profiled the code
> and determined that in fact you have an unacceptable bottleneck
> which must be optimized to meet your requirements.
> 
> Don't get me wrong, there _are_ times to optimize.  You just
> shouldn't see them very often... and life is simpler that way. :)

Summarized: make it work, make it right, make it fast. (In that order).
 

-- 

Vennlig hilsen 

Syver Enstad



More information about the Python-list mailing list