In <[EMAIL PROTECTED]>, George Sakkis wrote: > Chris Brat wrote: > >> Wouldn't this only cause problems with large lists - for once off >> scripts with small lists it doesn't seem like a big issue to me. > > The extra memory to allocate the new list is usually a minor issue; the > important one is correctness, if the original list is referenced by > more than one names.
It's not the allocation of the new list itself that might be an issue but the content, which will be copied in this case, before the old list and its content is freed. If you have 200 MiB worth of strings in the list and change all 'u's to 'x's with large_list = [item.replace('u', 'x') for item in large_list] another list with 200 MiB strings will be created. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list