On Oct 18, 9:47 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
> 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
On Thu, Oct 18, 2007 at 11:57:10AM -, Paul Hankin wrote regarding Re:
Appending a list's elements to another list using a list comprehension:
>
> Not to me: I can never remember which of a.append and a.extend is
> which. Falling back to a = a + b is exactly what you want.
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?
That's what the
Paul Hankin <[EMAIL PROTECTED]> writes:
> Not to me: I can never remember which of a.append and a.extend is
> which.
Interesting, with me it's the other way around. Maybe it's because I
used Python before extend was available.
> Falling back to a = a + b is exactly what you want.
Not if you wa
Debajit Adhikary a écrit :
> I have two lists:
>
> a = [1, 2, 3]
> b = [4, 5, 6]
>
> What I'd like to do is append all of the elements of b at the end of
> a, so that a looks like:
>
> a = [1, 2, 3, 4, 5, 6]
>
> I can do this using
>
> map(a.append, b)
And what about a.extend(b) ?
> How do I
On Oct 18, 10:21 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> 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 t
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 fast
En Wed, 17 Oct 2007 18:03:56 -0300, Debajit Adhikary <[EMAIL PROTECTED]>
escribió:
> What in general is a good way to learn about little things like these?
> (I'm fairly new to the language)
>
> A google search for 'python list methods" did not turn up the +
> operator anywhere for me. Where cou
On Wed, 17 Oct 2007 21:40:40 +, Paul Hankin wrote:
> 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
On Wed, 17 Oct 2007 23:46:25 +, Debajit Adhikary wrote:
> On Oct 17, 5:40 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
>> To answer your question though: a += b is *not* the same as a = a + b.
>> The latter would create a new list and assign it to a, whereas a += b
>> updates a in-place.
>
> I
Debajit Adhikary wrote:
> On Oct 17, 5:40 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
>> To answer your question though: a += b is *not* the same as a = a + b.
>> The latter would create a new list and assign it to a, whereas a += b
>> updates a in-place.
>
> I know I'm being a little finicky here,
On Oct 17, 5:40 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
> To answer your question though: a += b is *not* the same as a = a + b.
> The latter would create a new list and assign it to a, whereas a += b
> updates a in-place.
I know I'm being a little finicky here, but how would someone know
that
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?
U
On Oct 17, 4:41 pm, Carsten Haese <[EMAIL PROTECTED]> wrote:
> On Wed, 2007-10-17 at 20:27 +, Debajit Adhikary wrote:
> > I have two lists:
>
> > a = [1, 2, 3]
> > b = [4, 5, 6]
>
> > What I'd like to do is append all of the elements of b at the end of
> > a, so that a looks like:
>
> > a = [1,
On Oct 17, 9:27 pm, Debajit Adhikary <[EMAIL PROTECTED]> wrote:
> I have two lists:
>
> a = [1, 2, 3]
> b = [4, 5, 6]
>
> What I'd like to do is append all of the elements of b at the end of
> a, so that a looks like:
>
> a = [1, 2, 3, 4, 5, 6]
>
> I can do this using
>
> map(a.append, b)
>
> How d
On Wed, 2007-10-17 at 20:27 +, Debajit Adhikary wrote:
> I have two lists:
>
> a = [1, 2, 3]
> b = [4, 5, 6]
>
> What I'd like to do is append all of the elements of b at the end of
> a, so that a looks like:
>
> a = [1, 2, 3, 4, 5, 6]
>
> I can do this using
>
> map(a.append, b)
>
> How
On Wed, 17 Oct 2007 20:27:14 +, Debajit Adhikary wrote:
> I have two lists:
>
> a = [1, 2, 3]
> b = [4, 5, 6]
>
> What I'd like to do is append all of the elements of b at the end of
> a, so that a looks like:
>
> a = [1, 2, 3, 4, 5, 6]
>
> I can do this using
>
> map(a.append, b)
This i
17 matches
Mail list logo