Letter

Letter

By Silas S. Brown

Overload, 24(136):24, December 2016


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






Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.