[Python-Dev] recursive closures - reference cycle (original) (raw)

Kristján Valur Jónsson kristjan at ccpgames.com
Wed Dec 9 13:03:52 CET 2009


-----Original Message----- From: python-dev-bounces+kristjan=ccpgames.com at python.org [mailto:python-dev-bounces+kristjan=ccpgames.com at python.org] On Behalf Of Greg Ewing Sent: 8. desember 2009 22:09 To: python-dev at python.org Subject: Re: [Python-Dev] recursive closures - reference cycle

You could use a class:

Yes, and a number of different workarounds. That's not really the issue. The issue is that what looks like a perfectly safe idiom (calling a function recursively) happens to create a reference cycle if that function is a closure. This is a non-obvious "gotcha" that I must now educate my team about.

Note that at least parts of the library strive to avoid reference cycles even though "gc" exists. An example being xlm.minidom.Document.unlink()

Cheers,

Kristján



More information about the Python-Dev mailing list