Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python as a numerical prototyping language.

Reply
Thread Tools

Python as a numerical prototyping language.

 
 
Carl
Guest
Posts: n/a
 
      12-16-2003
I have been using Python for quite some time now and I love it. I use it
mainly for explorative computing and numerical prototyping, ie testing and
trying out different kinds of algorithms and computational schemes. The use
of Python as my first-choice language has made me extremely productive.

Now, I have always believed that Python is a poor performer in terms of
numerical speed. My experience, however, is that the efficient use of
dictionaries, lists, precompiled numerical libraries, etc makes Python a
higly competitive language for scientific computing (in comparison with
more traditional languages such as C, C++ and different versions of
Fortran).

Where is Python heading? Will it be a viable replacement for traditional
number-crunching languages in the near-term future?

Carl
 
Reply With Quote
 
 
 
 
Oren Tirosh
Guest
Posts: n/a
 
      12-17-2003
On Tue, Dec 16, 2003 at 09:16:33PM +0100, Carl wrote:
> I have been using Python for quite some time now and I love it. I use it
> mainly for explorative computing and numerical prototyping, ie testing and
> trying out different kinds of algorithms and computational schemes. The use
> of Python as my first-choice language has made me extremely productive.
>
> Now, I have always believed that Python is a poor performer in terms of
> numerical speed. My experience, however, is that the efficient use of
> dictionaries, lists, precompiled numerical libraries, etc makes Python a
> higly competitive language for scientific computing (in comparison with
> more traditional languages such as C, C++ and different versions of
> Fortran).
>
> Where is Python heading? Will it be a viable replacement for traditional
> number-crunching languages in the near-term future?


It already is. When dealing with large vectors Numerical Python is your
friend. The overhead of the interpreter is negligible since most of the
time is spent in highly optimized vector operations.

When operations are done on individual objects Python is significantly
slower than compiled languages but psyco is making great progress in this
area. It already approaches the performance of C for simple code using
only integers and floats.

Oren

 
Reply With Quote
 
 
 
 
Mark Dufour
Guest
Posts: n/a
 
      12-17-2003
> When operations are done on individual objects Python is significantly
> slower than compiled languages but psyco is making great progress in this
> area. It already approaches the performance of C for simple code using
> only integers and floats.


What are the opinions about Psyco being able to achieve the same great
speedups for non-simple code at some point in the future? Is the looking up
of methods/attributes during run-time the biggest problem here? I would
assume that with ever-increasing computer speeds there's no theoretical limit
to what might be possible here.. exciting stuff, this!


Mark Dufour.
--
"The employment agency has selected an immature and unproven software package
and its functionality is at the best close to Office 97," said Microsoft
representatives.


 
Reply With Quote
 
Lou Pecora
Guest
Posts: n/a
 
      12-17-2003
In article <(E-Mail Removed)>,
Oren Tirosh <(E-Mail Removed)> wrote:

> > Where is Python heading? Will it be a viable replacement for traditional
> > number-crunching languages in the near-term future?

>
> It already is. When dealing with large vectors Numerical Python is your
> friend. The overhead of the interpreter is negligible since most of the
> time is spent in highly optimized vector operations.
>
> When operations are done on individual objects Python is significantly
> slower than compiled languages but psyco is making great progress in this
> area. It already approaches the performance of C for simple code using
> only integers and floats.
>
> Oren


This is good news. I, too, use Python preferentially for numerics,
especially exploration of algorithms and numerical techniques. I gave
up on Mathematica long ago (powerful, but awful for programming) and
I've avoided MatLab so far (good, but not as nice as Python to program
and expensive). Only problem ocassionally is that many engineers were
raised on MatLAB and expect to be handed MatLab files/scripts to just
run on their data.

I'll have to check Psyco. If it does what you say, that would be a BIG
step.

--
-- Lou Pecora
My views are my own.
 
Reply With Quote
 
Oren Tirosh
Guest
Posts: n/a
 
      12-18-2003
On Wed, Dec 17, 2003 at 11:41:16AM +0100, Mark Dufour wrote:
> > When operations are done on individual objects Python is significantly
> > slower than compiled languages but psyco is making great progress in this
> > area. It already approaches the performance of C for simple code using
> > only integers and floats.

>
> What are the opinions about Psyco being able to achieve the same great
> speedups for non-simple code at some point in the future? Is the looking up
> of methods/attributes during run-time the biggest problem here?


Object semantics are indeed the issue. I think that there are tricks that
could bring it very close to the performance of statically typed languages,
though. Something like caching of object attribute accessors using hash
tables indexed by the object type and the interned method name, possibly
combined with some dynamically generated code.

> I would assume that with ever-increasing computer speeds there's no
> theoretical limit to what might be possible here.. exciting stuff, this!


Improvement in computer speeds will do nothing to the performance gap
between Python and a compiled language running on the same computer. It
could make them irrelevant because both are fast enough. This is already
true for Python on modern processors for all but a handful of compute-
intensive applications - the original subject of this thread.

Oren

 
Reply With Quote
 
Mark Dufour
Guest
Posts: n/a
 
      12-18-2003

> Improvement in computer speeds will do nothing to the performance gap
> between Python and a compiled language running on the same computer. I


Computer speeds in itself will not help much in closing the gap, but that was
not what I meant. When computers become faster though, it becomes possible do
shift more and more optimization techniques into run-time. Java does a lot of
optimization during run-time, as does Psyco. I don't think these would have
been acceptible were computers much slower than they are today. Psyco and
Java both require enormous amounts of memory too I believe, especially Psyco,
although that's improving.

> could make them irrelevant because both are fast enough. This is already
> true for Python on modern processors for all but a handful of compute-
> intensive applications - the original subject of this thread.


Absolutely, Python will become more and more viable, and hence more popular,
just because of computers becoming faster all the time. Sort of like how C
and some other languages I forgot became more popular than assembly language,
I guess


Thanks,
Mark Dufour.
--
"The employment agency has selected an immature and unproven software package
and its functionality is at the best close to Office 97," said Microsoft
representatives.


 
Reply With Quote
 
Johannes.Nix@web.de
Guest
Posts: n/a
 
      01-02-2004
Carl <(E-Mail Removed)> writes:

> Now, I have always believed that Python is a poor performer in terms of
> numerical speed. My experience, however, is that the efficient use of
> dictionaries, lists, precompiled numerical libraries, etc makes Python a
> higly competitive language for scientific computing (in comparison with
> more traditional languages such as C, C++ and different versions of
> Fortran).


First, look at http://www.python.org/topics/scicomp/ .

I am using Python + Numeric since a few years for really
computing-intensive signal processing and real-time audio processing
(explorative noise reduction for hearing aids). I code at least twenty
times faster than I did in pure C. It works great and on some
occations execution speed has been five times faster than Matlab; on a
Linux system with kernel modifications, Python with C extensios can
achieve worst-case latencies of 20 milliseconds or less for
full-duplex audio processing. At the other hand side, I use it for
really computing-intensive stuff on a Linux cluster (LAM) with 32
nodes. Plus, it runs neatly on multiprocessor Alpha or Opteron
systems, and can run in embedded systems; no need for a graphic card.

Another quality of Numerical Python that it is very easy to integrate
C code and very mature stuff from Netlib. Scientfic code can be very
difficult to test and verify so a good code base for numerical
routines is paramount. An interesting project for Python would be to
integrate the GNU scientific library and important Netlib routines as
far as possible. The module philosophy of Python, as well as Python's
community culture, supports it very well to use existing code again.

One thing that is quite easy to do is to start coding everything in
Python and develop the algorithm; then identify the hot spots by using
the profiler, and move them to C. Something of the complexity of a MP3
player with net access and graphic user interface can be easily
implemented in Python+C today.

One point about Matlab: The basic Matlab is _expensive_. But in a
commercial environment Matlab with signal processing extensions costs
_tens of thousands of dollars_. If I were founding an engineering
startup, I would avoid Matlab if possible at all.

>
> Where is Python heading? Will it be a viable replacement for traditional
> number-crunching languages in the near-term future?
>


For applications like audio, script languages will replace C and C++
widely in few years, because processors are just fast enough.

In my eyes, what Python, and Open Source in general, is still lacking
is an very easy, fast and very high-quality library for scientific and
financial plotting, although there are lots of good and thougthful
beginnings like Gnuplot, OpenDX, and many more. This would be an
essential building block to foster the use of Python in science.

Another thing that is a hassle for real-time programming on
multiprocessor systems is the Global Interpreter Lock (GIL). For
signal processing and real time replacing the GIL by per-object locks
would be an advance comparable to Linux-2.0. Currently the best
workaround seems to be the use of shared memory and LAM (by the pypar
module).

Johannes

P.S.

The mail address above traps spam. Mail to
string.replace(address, 'web', 'uni-oldenburg')
 
Reply With Quote
 
Carl
Guest
Posts: n/a
 
      01-03-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> In my eyes, what Python, and Open Source in general, is still lacking
> is an very easy, fast and very high-quality library for scientific and
> financial plotting, although there are lots of good and thougthful
> beginnings like Gnuplot, OpenDX, and many more. This would be an
> essential building block to foster the use of Python in science.


I agree! I use Gnuplot, it works OK, but is not perfect. I am also not that
enthusiastic about the algebra syntax of the Numerics module. I wish it was
closer to the Matlab syntax, which is much easier to grasp.

Python + Numeric + pygsl + FFTW + ... is, according to my view, a very good
alternative to using Matlab, Scilab, or R. What is missing is a large, rich
scientific library, and a better syntax for manipulating matrices and
vectors. On the other hand, what Python has got is an enormous amount of
modules for doing almost anything. For instance, there are Python libraries
for reading and writing to databases and building interfaces (very
important for building industry strength applications). So, if only Python
had a very large, rich, and fast library for numerical calculations and
scientific plotting I would be as happy as one can be.

I have used Matlab, Scilab, and R for quite some time. The last year,
however, I have started to use Python more and more. I wonder why? My guess
is that Python already is a viable environment for doing explorative data
analyses and testing numerical algorithms.

When it comes to speed, I feel that Python + Numeric is up to the task. For
example, I have been playing around with Monte Carlo simulation using list,
dictionaries, an numerical vectors and matrices as much as possible, and
have experienced performance very close to comparable code in C.

Carl


 
Reply With Quote
 
Lonnie Princehouse
Guest
Posts: n/a
 
      01-04-2004
Johannes.Nix wrote in message news:
>
> One point about Matlab: The basic Matlab is _expensive_. But in a
> commercial environment Matlab with signal processing extensions costs
> _tens of thousands of dollars_. If I were founding an engineering
> startup, I would avoid Matlab if possible at all.


Absolutely.

About a year ago, I attempted to answer the question "Can Python
replace Matlab?" for my workplace. The conclusion was "Not quite
yet", for two reasons.

The first was purely human: Matlab is entrenched, and there's always
resistance to change (note: lots of people here still swear by Fortran
'77).

The second reason: there's no unified Python environment that gives
you easy access to plotting capability and an interpreter, a la
Matlab. Python has the ability to do everything Matlab can (and much
more!) but it still requires just enough expertise to find, install,
and learn the various scipy and plotting modules that only the
early-adopter types are willing to do it.

Matlab projects around here have a tendency to start as a few .m
scripts, and to eventually mature into some kind of end-user
application complete with a simple GUI. This is where Python really
outshines Matlab: Tkinter and wxPython are far superior to the GUI
library that's built into Matlab, and the OO nature of Python makes
these more sophisticated applications much easier to develop and
maintain.
 
Reply With Quote
 
Fernando Perez
Guest
Posts: n/a
 
      01-06-2004
Lonnie Princehouse wrote:

> About a year ago, I attempted to answer the question "Can Python
> replace Matlab?" for my workplace. The conclusion was "Not quite
> yet", for two reasons.
>
> The first was purely human: Matlab is entrenched, and there's always
> resistance to change (note: lots of people here still swear by Fortran
> '77).
>
> The second reason: there's no unified Python environment that gives
> you easy access to plotting capability and an interpreter, a la
> Matlab. Python has the ability to do everything Matlab can (and much
> more!) but it still requires just enough expertise to find, install,
> and learn the various scipy and plotting modules that only the
> early-adopter types are willing to do it.


<plug>
While I completely agree with you that it still requires a fair amount of
manual labor to get a nice scientific python environment going, you may want
to take a look at ipython at http://ipython.scipy.org. It tries to provide as
good of an interactive shell as is feasible, along with improving on the
default Gnuplot support which Gnuplot.py provides (basically giving simpler
syntax for the plotting commands). With its concept of profiles, you can
simply say

ipython --profile numeric

and have a command-line shell which preloads a complete matlab-like
environment. It's not perfect, but users seem to like it.
</plug>

Regards,

Fernando.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fast and easy GUI prototyping with Python erokar@gmail.com Python 10 06-23-2008 07:34 PM
Simple prototyping in Python Dave Benjamin Python 10 05-05-2004 03:25 AM
Announcing new scripting/prototyping language Dave Allison C++ 37 03-04-2004 05:45 PM
Re: No call for Ada (was Re: Announcing new scripting/prototyping language) Ludovic Brenta C++ 86 02-19-2004 09:19 AM
Prototyping rules/recommendations sought rs C Programming 13 12-01-2003 10:13 PM



Advertisments