Efficient string concatenation methods
Peter Hansen
peter at engcorp.com
Sun May 2 16:36:43 EDT 2004
Oliver Crow wrote:
> Peter Hansen <peter at engcorp.com> wrote in message news:<s8OdnbvjBMT-ygndRVn-iQ at powergate.ca>...
>
>>You left out the StringIO module (having done only the cStringIO
>>version of that).
>
> I should probably add that one just for reference. I left it out
> originally because my instinct was that it would perform less well
> than the string += operator. I think it uses ordinary immutable
> python strings for internal storage.
Actually (I just checked the source) it uses a list, more like
example 4, but with some automated joining to the string form
at different times, depending on what's going on with reads()
and seeks() and such. I didn't bother trying to understand
it all, just to verify that it actually uses lists too.
-Peter
More information about the Python-list
mailing list