1. 2

  2. 1

    He’s using Python as an example of non refcounted garbage collection, but historically Python was refcounted with cycle breakers - is it now fully mark sweep?

    1. 2

      Python is still ref counting with cycle detection. It’s extraordinarily difficult to change because every function in every C extension is littered with Py_INCREF, Py_DECREF, etc.

      FWIW one thing I really learned in implementing a collector is how “littered all over” the codebase memory management is. It’s hard to change later, unless you have a layer of indirection like PyPy or Oil, which I mentioned here:


      I think non-moving tracing (e.g. mark and sweep) is the least “littered all over” of all strategies

      Aside: Looks like they have a new dev guide which is kinda cool, haven’t seen this:


      1. 2

        Yeah I would have been shocked if they managed to change it, though there are ways (for example you could have a non-zero refcount push an object into a separate root table, though then you need manage cycle breaking again :) ).