Faqts : Computers : Programming : Languages : Python : Python and Other Languages : Comparing

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

23 of 28 people (82%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How do Python and Visual Basic compare?

May 25th, 2000 08:11
unknown unknown, Michael Chermside, Janko Hauser, Erik Wilsher, Travis Oliphant


Look into the topic guide at http://www.python.org/topics/scicomp/
There you will find links to many tools for number crunching and I'm
sure that NumPy can withstand a comparison against Visual Basic,
although I would also be interested what is lacking.
You can also have a look at:
http://www.python.org/doc/Comparisons.html    (general)
http://lheawww.gsfc.nasa.gov/users/barrett/IDAE/table.1.html  
(specific).
-------
I have been programming in both (although I stopped with VB after I 
discovered Python:-), so here is a short summary.
If we look at the bare facts we have:
               Py         VB
Int*2          N          Y
Int*4          Y[1]       Y
Long[2]        Y          N
Real*4         N          Y
Real*8         Y          Y
Currency       N          Y
Array arith.   Y[3]       N[4]
Callbacks      Y[5]       Y
Modules        Y          Well, sort of
Dynamic        YES        N
Interactive    Y          Not very good
complex (not in VB) and exceptions (poor in VB)
1: Can be Int*8 on 64 bit machines
2: Long is abitary precision integer values
3: Through NumPy
4: Not that I know of
5: From within python only
[Insert : Through NumPy you have Int*2, and Real*4.]
Looking at the above, it can appear that the two languages are 
running head-to head.  But you should also consider:
1) You probably don't need real*4, real*8 is just as fast
2) You don't need int*2
3) VB makes some things extremly tedious. Compare
py>>> FiltConst = [1., 2., 1.5, 3.2, 6.2, 4.3]
VB:   Dim FiltConst(6) as Double
      FiltConst(1) = 1.
      FiltConst(2) = 2.
      etc....
4) The prototyping offered through an interactive environment 
(=Python) speeds up developement quite a lot.  The fact that you can 
include test code in your modules for easy testing lets you develop 
your application in a modular fashion and test each part 
before "assembly".
5) The speed issue is difficult:
a) If you run lots of matrix math you can use NumPy, and it is 
*fast*.  There is no alternative to NumPy in VB (to my knowledge)
[Insert:  You can use NumPy for lots of things besides just "matrix" 
math.  You can store large amounts of data in a small space and do rapid 
operations on that data as well.  As a result, image processing can be 
done very well using the NumPy object.]
b) If you on the other hand run lots of "itty nitty" numeric 
calculations VB is approx 15x faster than Python (highly informal 
test).
The question you need to ask yourselves on speed is "how fast is fast 
enough".  At present Python is (unfortunatly) not fast enough for our 
line of work (real time calculation of large ODE's), but the speed is 
sufficent for most other tasks.  If you find that Python is fast 
enough (execution speed), it offers great advantages in development 
speed!!
Have you tried multipack?  It contains a module that links the
FORTRAN integration routines in ODEPACK.  It is rather fast, but because
it calls a Python function at each step it is not "as fast as machinely
possible."  Still, a combination of Python/(C,FORTRAN) is very fast.