Python vs. Matlab

Hello Travis,

I worked about 7 years with Matlab, but at the end I gave up and I switched
to Python. This is mainly due to the fact that with new Matlab releases
(starting from R14) it is almost impossible to build a distributable
executable file. You can compile an application into an exe, but you have to
distribute such big files that I gave up. Moreover, GUI capabilities of
Python (wxPython) are much much (much)^Inf superior to Matlab ones.

Regarding your question:

They're mostly concerned about
cost and scriptability, but they're worried that the resulting Python
code would be very slow.

This much depends on how you use Matlab. If you use highly specialized
mathematical routines, image processing, optimization routines and
everything that involves large matrix computations (inversion,
decomposition, system solving etc...), I would be in doubt on which software
I would use.

Loops, conditionals and friends are much much faster in Python than in
Matlab, even using JIT acceleration.

Both software have a fast learning curve (in my opinion).

In case of large matrix computations, I would try to compare Matlab
capabilities to Python Numeric/scipy.

However, if you could specify a little bit more which use of Matlab you do,
I can probably give some more advice (even if I am not an expert with
Numeric/scipy, so my Python routines may have to be optimized by someone
else :wink: ).

HTH.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."

Just to add a few other comments about Python vs. Matlab.

Matlab strengths:

Very complete numerical library that is "just there", well integated and documented. With Python, you can find most of the same functionality, but it's a bit scattered, different libas aren't compatible with each other, etc. The SciPy project is heloping this a lot, but it's really not there yet.

Integrated plotting. Matplotlib has gone a long way to address this weakness for Python but it's only 2-d, etc.

Python+NumPy strengths:

Much better language: Better OO, more powerful flexible etc, etc, etc.

Much wider library support for things other than numerical work. Everything from text processing, full featured GUIs to Web developoment, etc. Also a huge number of C and C++ libs have been wrapped, for everything from GIS work to image processing.

Far more options for a full featured GUI.

NumPy supports wider variety of data types, integer types, etc.

Better support for arrays with more that 2 dimensions.

I like the NumPy array syntax/style better: elementwise is default, Array Broadcasting---yeah!

Indexing from 0 and slicing sytax end up being much cleaner:
  concatenate(a[a:b] + a [b:c]) = a ... it saves a lot of adding one, and checking the end cases.

More options for optimizing code, from simple stuff like in place operators: multiply(a,b,a) to SciPy.weave to Pyrex, to boost.

Easy ways to wrap exisiting code: SWIG, f2Py, etc.

Open source and platform independent.

Easier to create stand-alone appliations, and on ANY platfrom.

Do you need more?? Can you tell which one I use all the time these days? And I was a major fan of MATLAB before I discovered Python.

In short, I think Python+NumPy is inherently far supperior a developmet environment. The only thing is lacks is the clean integation and packaging that is often superior with comercial apps. That isn't a small issue. I haven't suggested Python to a few of my coleagues that use MATLAB for numerical prototyping. For the work they do, the extra effort to find out how to do what you need to do for Python is probably not worth it, from selecting a development environment, to docs, etc. Now that MPL is in pretty good shape, I'm almost ready to recomend a switch.

I do think that if you do any develpment beyond simnple numerical prototyping, you're better off with Python.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception