Replying to myself... the first sign of madness *wink*
Steven D'Aprano wrote: > size = 1024*1024*20 # 20 MB > original = "A" * size > copy = [None] * size > for i in range(size): > copy[i] = original[i].lower() > copy = ''.join(copy) Do you notice the premature optimization? Rather than appending new data to an initially empty list, I thought I would "optimize" my code by pre-allocating all the memory I would need for the list. You can see how well it didn't work: > This takes 530 seconds (8 minutes) The more sensible algorithm, without the unneeded pre-allocation of the copy list, runs 1000 times faster. That's the difference between optimization by wild guessing and optimization by actually writing good code :-) -- Steven. -- http://mail.python.org/mailman/listinfo/python-list