list addition methods compared.
Terry Reedy
tjreedy at udel.edu
Sun Dec 26 04:57:17 EST 2004
"Ishwor" <ishwor.gurung at gmail.com> wrote in message
news:34534aed0412252012638c85fd at mail.gmail.com...
> Hi all
> I have just wrote a small script to compare the speed of list addition
> methods.
There are two meanings of 'list addition':
li = li+[item] *copies* the list and adds item
li += [item] is the same as li.extend([item]) which add item to the end of
the list *without* copying.
Of course, extending a list is faster than copying + one more.
Terry J. Reedy
More information about the Python-list
mailing list