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)
>     Bart>     return mylist
>     Bart> #--------------------------------------------------
>
> Such an operation will be O(N**2), and thus expensive if performed
> frequently on lists of moderate length.  I've never been tempted to do this.

How can that be? Making a copy of a list is O(N), isn't it?

-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to