Concatenating a list of lists

Terry Reedy tjreedy at
Sun Aug 18 05:16:15 CEST 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