[SciPy-user] Concatenate without making a copy? + sandbox: models
robert.kern at gmail.com
Wed Jan 3 21:48:56 CST 2007
Vincent Nijs wrote:
> z = c_[d['x0'],d['x1']]
> Still makes a copy however. That is, if I set z[0,0] = -1, z is changed by d
> and x are not.
Correct. As I said, "in general" that is not the case, so c_ will copy.
> Is there an alternative command to c_ that would not make the copy?
No. You could write one (probably even in Python by abusing the
__array_interface__ appropriately) and perhaps convince Jonathon Taylor to use
it in scipy.sandbox.models, but the chance of a performance gain is almost
certainly not worth the effort or the multiplication of similar functions.
> Also, what if x.shape is (5,3). Could you concatenate d['x0'] and d['x2']?
Yes, you could concatenate them, but they would have to copy because they are
not laid out in memory appropriately.
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the SciPy-user