Deleting objects in Python 1.6

Thomas A. Bryan tbryan at python.net
Thu May 4 08:07:33 EDT 2000


Michael Hudson wrote:
> 
> Try this:
> 
> >>> l=[[]]
> >>> m=l[0]
> >>> for i in range(100000):
> ...     m.append([])
> ...     m = m[0]
> ...
> >>> del l
> 
> (hint: it segfaults on my machine, unless I use a v. new Python)

Interesting.  I caused Python to segfault once on Solaris.  I wonder 
whether this problem was the cause.  Then again, your code works on 
my little Linux box...

Python 1.5.2 (#1, Apr 18 1999, 16:03:16)  
[GCC pgcc-2.91.60 19981201 (egcs-1.1.1  on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> l = [[]]
>>> m = l[0]
>>> for i in range(100000):
...     m.append([])
...     m = m[0]
... 
>>> del l
>>> 

---Tom



More information about the Python-list mailing list