merging really huge lists fast

Joshua Macy amused at webamused.com
Sun Feb 13 12:39:30 EST 2000


thomas wrote:
> 
> Hi,
> 
> I got huge lists I want to merge, but the good old new_list = list1 +
> list2 seems to be slow. Any hints?
> 
> Thomas


  new_list = list1 + list2 creates a new list containing a (shallow)
copy of the elements of list1 and list2.  list1.extend(list2) will
append list2 to the end of list1.  My guess, without timing it, is that
the latter would be faster for huge lists, although it changes the
semantics...

  Joshua



More information about the Python-list mailing list