On Sat, 2003-04-05 at 21:02, Jeremy Hylton wrote: > #1. (I think this was Fred's suggestion on Friday.) Don't do a > hasattr() check on the object, do it on the class. This is what happens > with new-style classes in Python 2.3: If a new-style class doesn't > define an __del__ method, then its instances don't have finalizer. It > doesn't matter whether the specific instance has an __del__ attribute. FWIW, IIRC Jython does something vaguely like this. Actually the existance of __del__ is check at class creation time because it's expensive to call __del__ when the object is Java gc'd, and we use two different Java classes for classic class instances depending on whether it had a __del__ or not. This means you can't add __del__ to the class or the instance after the class is defined. Personally I think this is reasonable and I don't recall this biting anyone when I was working on Jython. -Barry
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4