Silas S. Brown comments on Steve Love's recent article.
Hi Steve,
Just read your article "A Lifetime in Python" in Overload 133 and the sentence "It will (probably) be garbage collected at some indeterminate point in the future". That's true of the Java implementation of Python, but the C implementation does reference counting, so it is able to delete objects as soon as the last reference to them falls out of scope; the garbage collector is used only as a backup in case of cyclic references. So in this case the db object will be deleted when addCustomerOrder returns, unless its internal structure contains references back to the parent object, in which case yes it will be garbage collected when the gc next runs (which is usually once every fixed number of bytecode instructions).
But that's only a small observation on an excellent article.
Thanks.
Silas S. Brown
And Steve replies:
Hi Silas,
Thanks for the feedback. I was trying to convey the idea that the object may or may not be garbage collected, but I guess it's not that clear that some platforms don't use a gc routinely.
But whether the object is ref counted, gc'd or anything else, it still won't have "close" called on it.
In any case, I think this is a nice clarification on the python lifetime management, and would be happy to see it as a letter, if you're happy with that.
Cheers
Steve