Terry Reedy wrote:
> Steve Holden wrote:
>> David Niergarth wrote:
[...]
>>> I'm not sure what deleting a slice accomplishes (del x[:]); the
>>> behavior is the same whether I do del x or del x[:]. Any ideas?
>>>
>> del x removes the name x from the current namespace, garbage collecting
>> the object to which it referred.
> 
> If there is another reference to the list, which there well might be in
> an actual application with memory problems, then 'del x' only
> disassociates the name but the object and its large contents are not gc'ed.
> 
>> del x[:] leaves x referencing a cleared list.
> 
> which is guaranteed to be cleared, regardless of other refs.
> 
Nice catch, Terry! You correctly spotted I was assuming that d
represented the only reference to the list.

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to