Concatenating a list of lists

Terry Reedy tjreedy at udel.edu
Sat Aug 17 23:16:15 EDT 2002


If there are a lot of lists, following might be faster than adding the
lists one at a time:

sum up lengths of lists
allocate list with that sum as length (sum*[0])
copy each list into preallocated list

This is list equivalent of algorithm I believe used by string.join().

Terry J. Reedy







More information about the Python-list mailing list