Experiences about Signal Processing with Numerical Python

Travis Oliphant olipt at mayo.edu
Tue Mar 14 12:41:02 EST 2000


> Hi,
> 
> I have looked a little bit into Python as an alternative to do
> research about signal processing algorithms. Currently nearly all
> members of my group use Matlab, and it is a bit hard to convince
> someone that another language could be more appropiate. My specific
> task involves developing quite large programs (the C equivalent would
> be more than 10000 lines), and the demand to work in a explorative and
> experimental way and make (perhaps as soon as possible) a real-time
> implementation (the kind of work I do was done before with dedicated
> DSP systems which are very time-consuming to program).

Hi Johannes,

I was an avid Matlab fan of six years before I made the change to
Numerical Python a couple of years ago.  In fact, I used to be called the 
Matlab guru where I am studying.  The short answer to your question about
signal processing in Python is yes, definitely yes.  In addition, if your
experience is like mine you will be glad you did.

I do large amounts of image processing and numerical algorithm development
with Python and it's Numerical Extensions and I've done a fair bit of the
same work with Matlab.  Here's my take:

Matlab is a nice interactive environment for small problems with a
consistent plot interface and a whole slew of ready-to-use builtin
functions.   When your problems get large, or the coding required to
express them is complicated,  Python's superior language, Numerical
Python's handling of multiple data types, and the ease of integration 
of Fortran and C subroutines, makes it a better choice.

The plotting for me has been tolerable.  I use gist for fast-and-easy
plotting and Dislin for publication-quality plotting (the new
object-oriented wrapper around dislin, makes it much easier to use).

The most compelling reason for me not to use Matlab is that I can deliver
solutions to people without burdening them with a commitment to the
MathWorks.

I have been slowly working to improve Numerical Python (a self-inflicted
role which I could never have even approached with Matlab).  I've
especially been interested in developing routines to make Numerical Python
easier to use for the signal processing community.  I've "started" a
project called PyLab which will include all of the modules which are right
now only available separately at http://oliphant.netpedia.net  One of
these modules is aimed directly at signal processing.  These modules work
in conjunction with Numerical Python to enhance the "toolbox."  There is
more work to do, but you might take a look and decide whether or not you
can share in the vision.   Right now the PyLab work is pending some basic
ground work on the Numerical Python module itself.

Finally, an example.  While I was making the transition to Numerical
Python, I wrote an MRI simulator in Matlab.  I wrote the same code in C++
and then in Python.  The results are interesting.  The Matlab code was
very slow which made me give up on the idea of doing it in a "high-level"
language.  The C++ code was much faster, but the surprising thing to me
was that the Python code was even faster than the C++ code.  The reason
was that because Python was interactive and high-level (no pointers to
track and compiling to do), I could think more about what I was
telling the computer to do and was able to eliminate slow-downs that
I couldn't see in C++.   Now, of course, I could re-code the slowest parts
in C or Fortran and link them in to Python and get the best of both 
worlds.  

For me that is what I've learned.  Do the high-level development and
"program-structuring" in Python and use compiled code to do speed up the
results.   Because Matlab is such a poor language to "program" in it is
hard to think this way for large problems with Matlab.  With PyLab I'm
trying to coordinate the development of a large collection of
"already-compiled" routines that can mean more and more work is done in
Python.

Good luck in your search.  

Sincerely,

Travis Oliphant





More information about the Python-list mailing list