Memory Leak ['LBBW': checked]

Josiah Carlson jcarlson at nospam.uci.edu
Wed Feb 25 17:24:21 EST 2004


> alist[:] creates a shallow copy of alist, which is a new object. del then
> decreases the refcount of this
> temporary object, thus it is destroyed. But why is the original alist empty
> after that, why are the
> list elements destroyed?
> Does that mean if a shallow copy of a list is created, the refcounts of the
> elements in the list are not increased?

Because del alist[:] is a special case.

Check the documentation on mutable sequence types:
http://www.python.org/doc/lib/typesseq-mutable.html

  - Josiah



More information about the Python-list mailing list