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

Citi, Luca lciti at essex.ac.uk
Tue Sep 22 18:14:52 EDT 2009


My vote (if I am entitled to) goes to "change the code".
Whether or not the addressee of .base is an array, it should be "the object that has to be kept alive such that the data does not get deallocated" rather "one object which will keep alive another object, which will keep alive another object, ...., which will keep alive the object with the data".
On creation of a new view B of object A, if A has ONWDATA true then B.base = A, else B.base = A.base.

When working on
http://projects.scipy.org/numpy/ticket/1085
I had to walk the chain of bases to establish whether any of the inputs and the outputs were views of the same data.
If "base" were the ultimate base, one would only need to check whether any of the inputs have the same base of any of the outputs.

I tried to modify the code to change the behaviour.
I have opened a ticket for this http://projects.scipy.org/numpy/ticket/1232
and attached a patch but I am not 100% sure.
I changed PyArray_View in convert.c and a few places in mapping.c and sequence.c.

But if there is any reason why the current behaviour should be kept, just ignore the ticket.

Luca



More information about the NumPy-Discussion mailing list