Python is the popular Machine Learning and Artificial Intelligence programming language, but it’s also the least favored because of slowness in addressing such loop problems.

To challenge this fact, EPFL researchers published a report in which they presented Python’s competitiveness against C++ and Go by solving the famous N-queens puzzle.

Comparison Of Python, C++ And Go In The N-Queens Solution

The problem with N-Queens involves organizing N-Queens on NxN so that no Queens can hit another Queen (not two Queens can appear horizontally, vertically or diagonally in the same way).

Researchers solved the puzzle of the N-queens using sequential and parallel methods in C++, Python and Go. We argued that even if C++ wins the race and Go, Python is easier when it is compiled using the Numba compiler.

The tests were demonstrated with the regular 8×8 and 10×10 for solving and running all versions of code on Catalina OS on 2.9GHz Quad-Core Intel Core i7.

We also removed all the code from a Ubuntu 18.04 running Intel Xeon X5690 CPU, and the overall ranking of the implementations remained unchanged.

Result Of Sequential And Parallel Processing

A repeating algorithm is the best way to completely calculate the N-queen problem. The solution was that there was no conflict between two queens as they should not be on the same line, on the same column or on the same diagonal.

During sequence processing, the Python, Go and C++ implementation indicated that Python was the slower. However, when the same code was compiled with the Numba Python compiler, C++ won 6 percent slower and Numba Python 12 percent slower.

They concluded that C++ and Go are similar to hardware and can be useful for fine-tuning code under certain conditions where Go is seen as an alternative to both Python and C++ due to its run-time control.

In order to continue integrating Python, Go and C++ in parallel they divided Python into Para and Pool based on two methods for running Python on a multicore CPU.

The result showed that the Para Numba compiled code shows significant improvement in parallel and is closer to C++ and Go. In addition, Python is successful in achieving greater values, but C++ is still faster.

Overall, the study shows that the slowness of Python can largely be overcome by using a Numba compiler that performs more quickly than Go, comparable to the performance of C++.

LEAVE A REPLY

Please enter your comment!
Please enter your name here