On Mon, Sep 15, 2014 at 12:31 PM, Eelco Hoogendoorn
<hoogendoorn.ee...@gmail.com> wrote:
> I figured the reference to the object through the local scope would also be
> tracked by the GC somehow, since the entire stack frame can be regarded as a
> separate object itself, but apparently not.

Objects are "tracked", not references. An object is only considered
"tracked" by the cyclic GC if the cyclic GC needs to traverse the
object's referents when looking for cycles. It is not necessarily
"tracked" just because it is referred to by an object that is
"tracked". If an object does not refer to other objects, *OR* if such
references cannot create a cycle for whatever reason, then the object
does not need to be tracked by the GC. Most ndarrays fall in that
second category. They do have references to their base ndarray, if a
view, and their dtype object, but under most circumstances these
cannot cause a cycle. As Sebastian mentioned, though, dtype=object
arrays can create cycles and should be tracked. We need to implement
the "tp_traverse" slot in order to do so.

-- 
Robert Kern
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to