Python / Visual Basic mathematical comparison
Erik Wilsher
erik.wilsher at iname.com
Wed May 24 07:12:47 EDT 2000
> if anyone can offer up opinions based on experience.
>
> Specifically, I am interested in where either language is more
> comprehensive in built-in elements used for prototyping or
developing
> financial or mathematical programs.
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
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
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)
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!!
More information about the Python-list
mailing list