[Python-Dev] Linus on garbage collection (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Sat May 7 01:53:39 CEST 2011
- Previous message: [Python-Dev] Linus on garbage collection
- Next message: [Python-Dev] Problems with regrtest and with logging
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Mark Shannon wrote:
For example, a file object will close itself during finalization, but its still a valid object, just a closed file rather than an open one.
It might be valid in the sense that you won't get a segfault. But the point is that the destructors of some objects may be relying on other objects still being in a certain state, e.g. a file still being open.
One would have to adopt a highly defensive coding style in destructors, verging on paranoia, to be sure that one's destructor code was completely immune to this kind of problem.
All of this worry goes away if the destructor is not a method of the object being destroyed, but something external that runs after the object has disappeared.
-- Greg
- Previous message: [Python-Dev] Linus on garbage collection
- Next message: [Python-Dev] Problems with regrtest and with logging
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]