Paul Rubin wrote:

> The usual Python idiom for building up a string in approx linear time
> is:
>
>    def cstring(n):
>       ret = []
>       while (something):
>         ret.append(generate_another_character())
>       return ''.join(ret)
>
> Python lists have a special efficiency hack so that ret.append doesn't
> copy the whole list around, but rather, allocates space in bigger
> chunks so that appending usually takes constant time.

in 2.4 and later, += on strings does the operation in place when
possible.  this means that += is often faster than append/join.

</F>



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to