|
|
Subscribe / Log in / New account

Progress on the Gilectomy

Progress on the Gilectomy

Posted Jun 2, 2017 3:12 UTC (Fri) by lhastings (guest, #66451)
Parent article: Progress on the Gilectomy

> Hastings tried to use a separate reference count to support weakref, but isn't sure that will work. Mark Shannon may have convinced him that resurrecting objects in __del__() methods will not work under that scheme; it may be a fundamental limitation that might kill Gilectomy, Hastings said.

Some clarification on this.

First: my approach for weakref works fine. I'm not sure how Jake got it in his notes that I wasn't sure. It's probably my fault, I'm sure I explained it badly!

Second, regarding resurrecting objects under __del__. The complicated problem was figuring out how, for a resurrected object, to know that we shouldn't free the object, and how we could safely call __del__ a second (and third...) time. I came up with a mildly complicated but safe / correct / workable scheme with relatively-little overhead--at the very least, a good starting point. And then! It turns out that there are new semantics for this as of Python 3.4, courtesy of PEP 442 "Safe object finalization". This guarantees that __del__ will only be called for an object exactly once. If an object is resurrected inside __del__, the second time its reference count drops to zero, the object is simply freed--__del__ isn't called again. These semantics are actually quite easy to support, particularly for the Gilectomy. Long story short, resurrection under __del__ is no problem.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds