Paul Hankin <[EMAIL PROTECTED]> writes:

> On Oct 17, 10:03 pm, Debajit Adhikary <[EMAIL PROTECTED]> wrote:
>> How does "a.extend(b)" compare with "a += b" when it comes to
>> performance? Does a + b create a completely new list that it assigns
>> back to a? If so, a.extend(b) would seem to be faster. How could I
>> verify things like these?
>
> Use a += b rather than a.extend(b): I'm not sure what I was
> thinking.

Why?  a.extend(b) is at least as readable, and is guaranteed to extend
the same list.  In general, "a += b" can fall back to the slower "a =
a + b" for sequences that don't support +=.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to