a.extend(b) better than a+=b ?

2010-04-22 Thread candide
Suppose a and b are lists. What is more efficient in order to extend the list a by appending all the items in the list b ? I imagine a.extend(b)to be more efficient for only appendinding the items from b while a+=b creates a copy of a before appending, right ? --

Re: a.extend(b) better than a+=b ?

2010-04-22 Thread Alf P. Steinbach
* candide: Suppose a and b are lists. What is more efficient in order to extend the list a by appending all the items in the list b ? I imagine a.extend(b)to be more efficient for only appendinding the items from b while a+=b creates a copy of a before appending, right ? No. But in

Re: a.extend(b) better than a+=b ?

2010-04-22 Thread Stefan Behnel
candide, 22.04.2010 09:10: Suppose a and b are lists. What is more efficient in order to extend the list a by appending all the items in the list b ? I imagine a.extend(b)to be more efficient for only appendinding the items from b while a+=b creates a copy of a before appending, right ?

Re: a.extend(b) better than a+=b ?

2010-04-22 Thread Peter Otten
candide wrote: Suppose a and b are lists. What is more efficient in order to extend the list a by appending all the items in the list b ? I imagine a.extend(b)to be more efficient for only appendinding the items from b while a+=b creates a copy of a before appending, right ? No. Both

Re: a.extend(b) better than a+=b ?

2010-04-22 Thread candide
Alf P. Steinbach a écrit : * candide: Suppose a and b are lists. What is more efficient in order to extend the list a by appending all the items in the list b ? I imagine a.extend(b)to be more efficient for only appendinding the items from b while a+=b creates a copy of a before

Re: a.extend(b) better than a+=b ?

2010-04-22 Thread Steven D'Aprano
On Thu, 22 Apr 2010 09:31:12 +0200, candide wrote: Alf P. Steinbach a écrit : * candide: Suppose a and b are lists. What is more efficient in order to extend the list a by appending all the items in the list b ? I imagine a.extend(b)to be more efficient for only appendinding the items

Re: a.extend(b) better than a+=b ?

2010-04-22 Thread Raymond Hettinger
On Apr 22, 12:10 am, candide cand...@free.invalid wrote: Suppose a and b are lists. What is more efficient in order to extend the list a by appending all the items in the list b ? I imagine a.extend(b)to be more efficient for only appendinding the items from b while a+=b creates a copy of a