Re: in place-ness of list.append

2007-02-05 Thread skip
as> I'm pretty confident append itself (and a+[n]) are linear in as> N=len(a) ... Yes, as I indicated in an earlier reply. The overall construction of his data structure would be O(N**2) or O(N*log N). The latter is for binary tree construction, but I didn't know what the OP was going t

Re: in place-ness of list.append

2007-02-05 Thread Alexander Schmolck
Alexander Schmolck <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] writes: > > > > "Bart" == Bart Van Loon <[EMAIL PROTECTED]> writes: > > > > >> Such an operation will be O(N**2), > > > > Bart> why is that? > > > > The a[:] operation makes a copy of a (as will the x = a + [n] idi

Re: in place-ness of list.append

2007-02-05 Thread Alexander Schmolck
[EMAIL PROTECTED] writes: > > "Bart" == Bart Van Loon <[EMAIL PROTECTED]> writes: > > >> Such an operation will be O(N**2), > > Bart> why is that? > > The a[:] operation makes a copy of a (as will the x = a + [n] idiom). I'm pretty confident append itself (and a+[n]) are linear in

Re: in place-ness of list.append

2007-02-05 Thread skip
> "BJörn" == BJörn Lindqvist <[EMAIL PROTECTED]> writes: BJörn> On 2/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> Bart> #-- Bart> def addnumber(alist, num): Bart> """ work around the inplace-ness of .append """ B

Re: in place-ness of list.append

2007-02-05 Thread BJörn Lindqvist
On 2/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Bart> #-- > Bart> def addnumber(alist, num): > Bart> """ work around the inplace-ness of .append """ > Bart> mylist = alist[:] > Bart> mylist.append(num) >

Re: in place-ness of list.append

2007-02-05 Thread skip
> "Bart" == Bart Van Loon <[EMAIL PROTECTED]> writes: >> Such an operation will be O(N**2), Bart> why is that? The a[:] operation makes a copy of a (as will the x = a + [n] idiom). Bart> I am building a binary tree where each node is a list. the two Bart> children are the p

Re: in place-ness of list.append

2007-02-05 Thread Bart Van Loon
It was Mon, 5 Feb 2007 05:01:28 -0600, when [EMAIL PROTECTED] wrote: > > Bart> #-- > Bart> def addnumber(alist, num): > Bart> """ work around the inplace-ness of .append """ > Bart> mylist = alist[:] > Bart> mylist.app

Re: in place-ness of list.append

2007-02-05 Thread Bart Van Loon
It was Mon, 05 Feb 2007 11:00:50 GMT, when Kent Johnson wrote: > Bart Van Loon wrote: >> Hi all, >> >> I would like to find out of a good way to append an element to a list >> without chaing that list in place, like the builtin list.append() does. >> >> currently, I am using the following (for a

Re: in place-ness of list.append

2007-02-05 Thread Robin Becker
Bart Van Loon wrote: > Hi all, > ... > > #-- > def addnumber(alist, num): > """ work around the inplace-ness of .append """ > mylist = alist[:] > mylist.append(num) > return mylist > #

Re: in place-ness of list.append

2007-02-05 Thread Kent Johnson
Bart Van Loon wrote: > Hi all, > > I would like to find out of a good way to append an element to a list > without chaing that list in place, like the builtin list.append() does. > > currently, I am using the following (for a list of integers, but it > could be anything, really) > > #---

Re: in place-ness of list.append

2007-02-05 Thread skip
Bart> #-- Bart> def addnumber(alist, num): Bart> """ work around the inplace-ness of .append """ Bart> mylist = alist[:] Bart> mylist.append(num) Bart> return mylist Bart> #