Joshua Marshall jmarshal at
Sat Feb 3 22:37:35 EST 2001

chris at wrote:
> On 4 Feb 2001, Joshua Marshall wrote:

>> I'm plucking characters off a stream and concatenating them.
>> Currently, I'm doing something like:
>>    buf = []
>>    while stream.more():
>>       buf = buf +
>>    string.join(buf, '')
>> Is there a faster way?  I'm thinking of writing a Stringbuffer
>> class in C.  Or does a quick, reliable one already exist?

> You could try buf.append(

> And... I dont know what you're trying to achive with string.join(buf,'').
> Are you just adding a space?? :)

I'm using string.join to convert a list of strings into a single string.
My use of a list is for efficiency.  Intuitively, I'm trying to do:

   ret = ''
   while stream.more():
      ret = ret +

but this is too slow.  Appending to a list is better, but I'm looking
for more speed.

More information about the Python-list mailing list