[Numpy-discussion] is ndarray.base the closest base or the ultimate base?

Pauli Virtanen pav+sp@iki...
Mon Sep 21 05:11:43 CDT 2009


Mon, 21 Sep 2009 10:51:52 +0100, Citi, Luca wrote:
> Thanks for your quick answer.
> 
> Is there a reason for that?
> Am I wrong or it only makes life harder, such as:
> 
> while (PyArray_Check(base) && !PyArray_CHKFLAGS(base, NPY_OWNDATA)) {
>    base = PyArray_BASE(base);
> }
> 
> plus the possible error you underlined, plus the fact that this keeps a
> chain of zombies alive without reason.
> 
> Are there cases where the current behaviour is useful?

I don't see real merits in the current behavior over doing the chain up-
walk on view creation. I don't know if anything in view creation requires 
that the immediate base is alive afterwards, but that seems unlikely, so 
I believe there's no reason not to make this change.

Some (bad) code might be broken if this was changed, for example

>>> y = x[::-1]
>>> y.base is x

but in practice this is probably negligible.

-- 
Pauli Virtanen



More information about the NumPy-Discussion mailing list