[Python-Dev] recursive closure

Li Tianqing jazeltq at 163.com
Thu Sep 11 04:55:40 CEST 2014


Hello,
    Can someone explain me why gc(CPython) can not collect recursive closure's cycle reference?  There is no __del__ here, why gc can not collect?
    Thanks a  lot.


For example:
#!/usr/bin/env python


import ipdb
import gc


gc.set_debug(gc.DEBUG_LEAK)


def A():
N = [1]
def aa(n):
if n in N:
return 1
else:
return n * aa(n-1)


x = 33 + aa(10)
#ipdb.set_trace()
print x 




if __name__ == '__main__':
while xrange(1000):
A()








--

Best
    Li Tianqing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140911/f44db6df/attachment.html>


More information about the Python-Dev mailing list