Bazaar: Out of memory
Stefan Monnier
monnier at iro.umontreal.ca
Fri May 9 16:02:05 BST 2008
> The .join() method is faster because it does less memory allocations
> and copies than the for loop you list above. It should allocate a
> single string for the final concatenated string. In contrast, the for
> loop version does a string allocation and copy for every iteration (so
> in the final iteration you'd expect it to have allocated roughly twice
> the memory).
The amount of copying and allocation is not just double but O(N^2)
(basically N+(N-1)+(N-2)+...).
Stefan
More information about the bazaar
mailing list