Wednesday, May 8, 2013

Comparing execution speed of Python, NumPy, Matlab, Fortran, etc

This is an interesting comparison of the numerical performance of python, numpy, fortran, java and matlab in performing some array operations.

The post is outdated (it is from 2009). Still, it demonstrates the importance of vectorizing array operations. It also shows that lower level languages like fortran will almost always have the upper hand in execution speed (but development time can easily balance that in python).

It would be worth repeating this comparison with the newer versions of numpy, python, matlab and fortran compilers to see what has changed in terms of relative speedups among the different languages. It would also be nice to include a "parallel" case of these examples using some multiprocessing module in python in a multicore machine (e.g. multiprocessing, iPython parallel).

4 comments:

  1. It's a mistake to compare execution speeds only. You have to compare the time of the whole process, id est, since the problem is presented until the solution is given.

    Most of the scientist time related to computing is spent implementing the code and not running it.
    Besides, faster or parallel machines are cheaper than good programmers (not to speak good scientists).

    What I mean is you need to care about how easy is to implement a given algorithm; It's probably your bottleneck. Medium level languages are fast to run because you have to implement all the high level data structures, if you need them. High level languages have this embedded (the terms medium and high are not adequate)

    Anyway, contemporary languages like python are fun to work with, while fortran is pain. That's count too.

    ReplyDelete
  2. I completely agree with what you wrote.

    ReplyDelete
  3. Have you tried PyPy?
    Works miracles. Not with numpy though, don't think so.

    ReplyDelete
  4. I heard about pypy but haven't tried it yet, mainly because I am figuring out a way of making it coexist with my virtualenv python installation. I also have to play around more with cython.

    ReplyDelete