Okay, I had a flash of inspiration on the way home from my gig tonight. Of course, I'm also really tired so I'm sure Tim will shoot this down in his usual witty but humbling way. I just had to get this out or I wouldn't sleep tonight. What if you timestamp instances when you create them? Then when you have trash cycles with finalizers, you sort them and finalize in chronological order. The nice thing here is that the user can have complete control over finalization order by controlling object creation order. Some random thoughts: - Finalization order of cyclic finalizable trash is completely deterministic. - Given sufficient resolution of your system clock, you should never have two objects with the same timestamp. - You could reduce the memory footprint by only including a timestamp for objects whose classes have __del__'s at instance creation time. Sticking an __del__ into your class dynamically would have no effect on objects that are already created (and I wouldn't poke you with a pointy stick if even post-twiddle instances didn't get timestamped). Thus, such objects would never be finalized -- tough luck. - FIFO order /seems/ more natural to me than FILO, but then I rarely create cyclic objects, and almost never use __del__, so this whole argument has been somewhat academic to me :). - The rule seems easy enough to implement, describe, and understand. I think I came up with a few more points on the drive home, but my post jam, post lightbulb endorphodrenalin rush is quickly subsiding, so I leave the rest until tomorrow. its-simply-a-matter-of-time-ly y'rs, -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