emptying a list

S.Selvam s.selvamsiva at gmail.com
Fri Oct 2 01:56:16 EDT 2009


On Thu, Oct 1, 2009 at 10:13 PM, Jon Clements <joncle at googlemail.com> wrote:

> On 1 Oct, 16:30, "lallous" <lall... at lgwm.org> wrote:
> > Hello
> >
> > What is faster when clearing a list?
> >
> > del L[:]
> >
> > or
> >
> > L = []
> >
> > --
> > Elias
>
> Does it really matter that much?
>
> And you're really talking about two different things, which quite
> often come up on this group.
>
> Example follows:
>
> >>> x = range(5)
> >>> x = y
>

Is n't it y=x ?

>>> print x, y
> [1, 2, 3, 4] [1, 2, 3, 4]
> >>> x = []
> >>> print x, y
> [] [1, 2, 3, 4]
> >>> x = y
> >>> print x, y
> [1, 2, 3, 4] [1, 2, 3, 4]
> >>> del x[:]
> >>> print x, y
> [] []
>
> Cheers,
> Jon.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Yours,
S.Selvam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091002/4fbdf90c/attachment-0001.html>


More information about the Python-list mailing list