3 ms·
I thought the GC in most python implementations was deterministic. According to http://www.digi.com/wiki/developer/index.php/Python_Garbage_Collection http://w
by recursive 13y ago
I thought the GC in most python implementations was deterministic. According to http://www.digi.com/wiki/developer/index.php/Python_Garbage_Collection http://www.digi.com/wiki/developer/index.php/Python_Garbage_... it does use a reference counting system, which is some inconclusive evidence. Does anyone know for sure?
- ggchappell 13y agoFrom the documentation of the Python 3.3 data model[1]: > CPython currently uses a reference-counting scheme with (optional) delayed detection of cyclically linked garbage, which collects most objects as soon as they become unreachable, .... Other implementations act differently and CPython may change. Do not depend on immediate finalization of objects when they become unreachable (ex: always close files). > object.__del__(self) Called when the instance is about to be destroyed. This is also called a destructor. ... It is not guaranteed that __del__() methods are called for objects that still exist when the interpreter exits. Summary: Don't count on it. Use "with". [1] http://docs.python.org/3.3/reference/datamodel.html http://docs.python.org/3.3/reference/datamodel.html
- ketralnis 13y agoSort of. CPython's main GC strategy is is refcounting, which is deterministic. It also does have a cycle-detecting GC that's not deterministic But this is an implementation detail, so it could change in the future. And CPython isn't the only implementation, either. IronPython, pypy, and Jython all have different GC characteristics.