On 1/18/07, Larry Hastings <[EMAIL PROTECTED]> wrote:
I just ran a quickie experiment and determined: when leaving a scope, variables are deleted FIFO, aka in the same order they were created. This surprised me; I'd expected them to be deleted LIFO, aka last first. Why is it thus? Is this behavior an important feature or an irrelevant side-effect?
Please regard it as an irrelevant side-effect. If you want objects to be cleaned up in a particular order, you should enforce it by having one of them refer to the other. A great many details can affect the order in which variables are cleaned up, and that only decreases refcounts of the actual objects -- a great many other details can then affect the order in which any objects left with a 0 refcount are actually cleaned up. Even not counting the more complicated stuff like GC and funky __del__ methods, just having 'import *' or a bare 'exec' in your function can change the order of DECREFs. -- Thomas Wouters <[EMAIL PROTECTED]> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com