Python’s Execution Time Is Close To C++ And Go Language: Study

python img

Python is the most preferred programming language for Machine Learning and Artificial Intelligence, but it is also the least preferred for being slow to solve certain problems that involve loops.

To challenge this fact, researchers at EPFL Computer Vision Laboratory published a report in which they presented the competitiveness of Python against C++ and Go by solving the popular N-queens puzzle.

Comparing Python, C++ and Go in solving N-Queens problem

The N-queens problem involves an arrangement of the N-queens on the NxN chessboard such that no queens can strike any other queen (no two queens can come in the same horizontal, vertical, or diagonal way).

The researchers solved the N-queens puzzle using both sequential and parallel methods written in C++, Python, and Go. They argued that although C++ wins the race followed by Go, Python also comes closer once compiled using the Numba compiler.

For demonstrating the result, they took the standard 8×8 and 10×10 board to solve and run all versions of code on 2.9GHz Quad-Core Intel Core i7 on Catalina OS.

They also reran all code on an Intel Xeon X5690 CPU running Ubuntu 18.04, and the overall ranking of the implementations remained unchanged.

Sequential and Parallel Processing result

A recursive algorithm is the best method to compute the N-queen problem completely. The solution relied on the fact that no two queens be in conflict with each other as they must not be on the same row, on the same column, or on the same diagonal.

In sequential processing, implementation in Python, Go, and C++ indicated that Python was the slowest. But when the same code was compiled using the Numba Python compiler, C++ still won with Go slower by 6% and Numba Python slower by 12%.

They concluded that C++ and Go, being closer to the hardware, may be useful to fine-tune code under some circumstances where Go can be considered an alternative to both Python and C++, because of its run-time check.

To further implement Python, Go, and C++ using parallel processing, they categorized Python into Para and Pool based on two approaches to run Python on a multicore CPU.

The result demonstrated that in parallelization, Para Numba-compiled code displays significant improvement and comes closer to the C++ and Go. Moreover, Python succeeds Go for larger values, but, C++ is still faster.

Overall, the study shows that the slowness of Python can largely be overcome by using the Numba compiler that delivers performance comparable to that of C++, which itself is faster than Go.

22 Comments

  1. Hey there. I discovered your website via Google while looking for a comparable matter, your website came up. It seems to be good. I have bookmarked it in my google bookmarks to visit then.

  2. I was just looking for this information for a while. After six hours of continuous Googleing, at last I got it in your site. I wonder what’s the lack of Google strategy that don’t rank this kind of informative sites in top of the list. Generally the top web sites are full of garbage.

  3. First of all I would like to say wonderful blog! I had a quick question in which I’d like to ask if you don’t mind.

    I was curious to find out how you center yourself and clear your thoughts before writing.

    I have had a difficult time clearing my thoughts
    in getting my thoughts out. I do enjoy writing however it just seems like the first 10
    to 15 minutes tend to be wasted simply just
    trying to figure out how to begin. Any suggestions or tips?
    Cheers!

  4. Thanks for sharing excellent informations. Your website is so cool. I am impressed by the details that you have on this web site. It reveals how nicely you perceive this subject. Bookmarked this website page, will come back for more articles. You, my friend, ROCK! I found just the information I already searched everywhere and simply couldn’t come across. What a perfect web site.

  5. I just wanted to construct a simple remark so as to express gratitude to you for some of the stunning tips and tricks you are giving out on this site. My considerable internet research has at the end been compensated with awesome suggestions to exchange with my friends and family. I ‘d say that we site visitors are really lucky to exist in a fabulous place with many brilliant people with very helpful strategies. I feel quite fortunate to have used the website and look forward to some more amazing times reading here. Thank you once more for a lot of things.

  6. Having read this I thought it was really enlightening. I appreciate you taking the time and energy to put this short article together.
    I once again find myself personally spending way too much
    time both reading and leaving comments. But so what, it was still worth it!

  7. Nice post. I learn something totally new and challenging on websites I stumbleupon on a daily basis.
    It’s always useful to read through content from other writers and use something from other websites.

Leave a Reply

Your email address will not be published.


*