[Python-Dev] Garbage collecting closures (original) (raw)
Paul Prescod paul@prescod.net
Mon, 14 Apr 2003 07:34:22 -0700
- Previous message: [Python-Dev] Garbage collecting closures
- Next message: [Python-Dev] Garbage collecting closures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Tim Peters wrote:
...
Hiding critical resources in closures is a Bad Idea, of course -- that's why nobody has used Scheme since 1993
Just to be clear, I didn't really intend to create a closure (i.e. a package of code and data). I just defined a function in a function because the inner function wasn't needed elsewhere.
I don't know what the solution is, but it seems quite serious to me that there is another special case to remember when reasoning about when destructors get called. Roughly, Python's cleanup model is "things get destroyed when nothing refers to them." Then, that gets clarified to "unless they have reference cycles, in which case they may get destroyed arbitrarily later" and now "or they are used in a function containing another function, which will cause a circular reference involving all local variables."
Paul Prescod
- Previous message: [Python-Dev] Garbage collecting closures
- Next message: [Python-Dev] Garbage collecting closures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]