3 ms·
How does that contradict what I was saying? The garbage collector would still close the file eventually, right? Unless of course it was copied somewhere else i
by Derbasti 12y ago
How does that contradict what I was saying?
The garbage collector would still close the file eventually, right? Unless of course it was copied somewhere else in the meantime, but in the code example, that is clearly not the case.
- Jweb_Guru 12y agoEventually, yes. But if you're relying on the file being deterministically closed (e.g. if you're using the POSIX file locking mechanism) in CPython, it won't necessarily be correct in non-reference counting garbage-collected languages, and the same is true if you're relying on any other sort of deterministic resource cleanup (e.g. in memory-constrained environments).