[mod_python] python print

Jonathan Gardner jgardner at jonathangardner.net
Tue Jun 10 12:27:03 EST 2003

Hash: SHA1

On Tuesday 10 June 2003 07:49, Scott Russell wrote:
> On Tue, 2003-06-10 at 09:35, Jonathan Gardner wrote:
> > B)
> > 	s = []
> > 	s.append('something')
> > 	s.appent('something more')
> > 	...
> > 	print "".join(s)
> >
> > B is far more efficient than A. This really shows up when you are
> > concatenating hundreds or more elements. Anything below that, it really
> > doesn't make too much of a difference.
> >
> Momma always says, "Make sure you can read it first, only optimize it
> after you profile." :)

You're right. This particular algorithm has been tested and profiled. I gave 
you the numbers I have found when I have done profiling. That is why I use 
this almost everywhere I have to concatenate multiple strings together. While 
it is true you shouldn't spend too much time optimizing on your first 
iteration of writing your code, it is silly to use methods you know are 
inefficient when comparable methods that are efficient exist and are 
well-tested. It just makes more work for the second and beyond iterations.

- -- 
Jonathan Gardner <jgardner at jonathangardner.net>
(was jgardn at alumni.washington.edu)
Live Free, Use Linux!
Version: GnuPG v1.2.1 (GNU/Linux)


More information about the Mod_python mailing list