Great question Far. The reason for this is that Python has immutable strings -- they are not implemented as linked lists internally. So when you do:
x = 'hi' x += 'a' x += 'b' x += 'c' the string is reconstructed completely each time. If you use a list then there is no reconstruction and the join -- turning the list into the string -- ends up being way more efficient. This is a common python idiom, btw. -philip On 2/7/07, Far McKon <[EMAIL PROTECTED]> wrote: > I see a lot of sycamore code using an array to add text, rather than a > string( example below) Is this a speed issue? A style issue? Why is > thing being done this way? I searched google groups a but, but didn't > find anything on it. > > Info? > > - Far > > EX: > outString = 'x' > outString += ' and y' > return outstrings > VS: > outstring = [] > outstring.append('x') > outstring.append(' and y') > return ''.join(outstring) > _______________________________________________ > Sycamore-Dev mailing list > [EMAIL PROTECTED] > http://www.projectsycamore.org/ > https://tools.cernio.com/mailman/listinfo/sycamore-dev > _______________________________________________ Sycamore-Dev mailing list [EMAIL PROTECTED] http://www.projectsycamore.org/ https://tools.cernio.com/mailman/listinfo/sycamore-dev