<>1, explain :

The test is in win10 Under the platform , Let's take a look at the configuration of the computer first :
testing environment :
Python3.6.4 GCC 8.1.0 # You need to install it yourself ~ G++ 8.1.0
<>2, test C and Python Add to 1 100 million , Time spent

<>2.1,C Language program

First use create Test.c file , And then Test.c File to DLL(Win Use under Python call DLL,Ubuntu Next call so).
Copy the following program to Test.c In the file , Then run it gcc -shared -o Test.dll Test.c generate DLL file
#include "stdio.h" // crux :__declspec(dllexport) Declare to export this method to DLL in . __declspec(
dllexport) int sum(int a) { while (a < 100000000) { /* code */ a = a + 1; } //
printf("%d", a); return a; }
<>2.2,Python program

establish python2c.py file , Copy the following program to python2c.py In the file , Then run it python2c.py
from ctypes import * import time from numba import jit dll = windll.LoadLibrary
('Test.dll') def c_calc_sum(): a=dll.sum(1) print(a) start_c = time.time()
c_calc_sum() print(time.time() - start_c) # @jit def calc_sum(): sum_py = 0 for
i inrange(100000000): sum_py = sum_py + 1 start_py = time.time() calc_sum()
print(time.time() - start_py)
The output is as follows :
100000000 0.15740251541137695 # explain :c Language calculation results 4.498934984207153 # explain :Python Language calculation results
The test above , It is used separately C Procedures and Python Program accumulation calculation 1+1+1+1…(1 100 million times )
We can see from the results , use C than Python It's about time 28 times .

<>3, test C and Python(numba accelerate ) Add to 1 100 million , Time spent

We just need to put the above python2c.py In file # @jit Note removed , That is, change to @jit That's it numba accelerate .
Take a look at how to use it numba After acceleration Python Operational efficiency of :
100000000 0.14839458465576172 # explain :c Language calculation results 0.16844749450683594 #
explain :Python Language calculation results
<>4, conclusion

We can see from the above results :
1, Use separately c and python Test from 1 Add up to 1 100 million ,c than python Almost 28 times (python Not used numba accelerate );
2, Use separately c and python Test from 1 Add up to 1 100 million ,c than python Almost 1.4 times (python use numba accelerate );

Technology