Why did I Choose Python ?

Why did I Choose Python ?

Python programming language which its main philosophy is ‘code readability’ has entered our lives in 1991. After the Python developer Van Rossum has decided to pursue his career on Google, Google has became the tower of strength of Python. Then Python’s popularity has begun to increase linearly. One common question arises in mind of most people, how Python has become popular although its slow ?  If you can’t believe or don’t want to believe, you should examine at the numerical data.

Reference: http://pypl.github.io/PYPL.html 

I have got caught up in this popularity trend and I chose a project where I could use the Python programming language when applying to the Summer of HPC program. What would you say about speed when you compare C and Python programming language? Of course, everyone will call it C. Actually I’m not trying to solve a known result of problem. I’m working on how much speed we can improve by doing code optimization in python. That’s when I met Numpy more closely.

in my dream python with numpy
in reality

NumPy (Numerical Python) is a mathematical library that allows us to perform scientific calculations quickly (many people confuse it with a module or framework but it’s a library).  Numpy arrays form the basis of Numpy. Numpy arrays are similar to python lists, but are more useful in terms of speed and functionality than python lists. Also, unlike python lists, Numpy arrays must be homogeneous,  all elements in the array must be of the same data type.

You know that you can write an algorithm in more than one way in a programming language. So I has written this problem in three different ways:

  • version 1 – Using the Numpy library
  • version 2 – Numpy not using the library
  • version 3 – Using the Numpy library and never using for loop

I have mentioned the CFD problem in my previous post. We have done many experiments by changing the parameters of this problem. There were 3 different parameters that could affect the speed of the algorithm. You can see the values :

  1. Scale factors of 1, 4, 16, 32 and 128
  2. For each scale factor, two cases: without Reynolds number and with Reynolds number
  3. For each case, run with error checking

How many runs do I need for all these cases?

5 (scale factor) * 2 (Reynold number) * 2 (Check error) * 4 (repeat) =
80 run ! (for each code)

I can say that there are big differences between speed performances. I will share the results in my next blog post.


Tagged with:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.