Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] __traceback__ and reference cycles

Tim Peterstim.peters at gmail.com
Tue Aug 9 05:02:59 CEST 2005


[Brett Cannon]> Wasn't there talk of getting rid of __del__ a little while ago and> instead use weakrefs to functions to handle cleaning up?There was from me, yes, with an eye toward P3K.> Is that still feasible?It never was, really.  The combination of finalizers, cycles andresurrection is a freakin' mess, "even in theory".  The way things areright now, Python's weakref gc endcase behavior is even moremystically implementation-driven than its __del__ gc endcase behavior,and nobody has had time to try to dream up a cleaner approach.> And if so, would this alleviate the problem?Absolutely <wink>.  The underlying reason for optimism is that    weakrefs in Python are designed to, at worst, let *other* objects    learn that a given object has died, via a callback function.  The weakly    referenced object itself is not passed to the callback, and the presumption    is that the weakly referenced object is unreachable trash at the time the    callback is invoked.IOW, resurrection was "obviously" impossible, making endcase life verymuch simpler.  That paragraph is from Modules/gc_weakref.txt, and youcan read there all about why optimism hasn't work yet ;-)


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp