[Numpy-discussion] Matlab vs. Python (Was: Re: [SciPy-Dev] Good-bye, sort of (John Hunter))

Sturla Molden sturla@molden...
Sun Aug 15 15:27:34 CDT 2010


> Matlab also takes a copy if we create an array slice. It means for example
> that a wavelet transform written in Python will be O(n) with respect to
> memory, whereas it will be O(n log n) in Matlab.

Other examples:

A reshape will create a new array in Matlab. It will create a view in NumPy.

A transpose will create a new array in Matlab and be O(m*n). A transpose
will just create a view in NumPy (i.e. reverse stride and shape
attributes) and be O(1).

Matlab does not broadcast. We must explicitely match array shapes using
repmat, which by the way creates a new array.

NumPy allows arrays to be updated inplace. Matlab always creates a new
copy (Matlab arrays are immutable).








More information about the NumPy-Discussion mailing list