Python vs Java garbage collection?

Ganesan R rganesan at myrealbox.com
Sun Dec 29 23:17:34 EST 2002


>>>>> "Stuart" == Stuart D Gathman <stuart at bmsi.com> writes:

> 1) This feature should not reclaim memory, only call __del__().  If
> references were still live, the effect would be the same as calling
> __del__() on a live object.

> 2) __del__() would get called again when memory is actually reclaimed.
> Therefore, your feature would be much safer if it called another special
> function - say close() or dispose() at the end of the block.

I actually like C# deterministic cleanup with the "using" block for
this. See http://www.25hoursaday.com/CsharpVsJava.html#idisposable.
I am not sure how to adopt this for Python. May be something like

using myobj as MyClass("A MyClass Object"): 
    do something with myobj
# runtime calls dispose on myobj object once "using" code block is exited,
# even if exception thrown. 

Ganesan
    
-- 
Ganesan R 



More information about the Python-list mailing list