When I am using Numba, the following error is happening:
Process finished with exit code -1073740940 (0xC0000374)
Here is the code:
from numba import njit,prange
@njit(parallel=True)
def r(x,y,z):
k=[]
for i in prange(x):
for j in prange(y):
for l in prange(z):
k.append(i + j+l)
return k
k = r(2,2,2)
Could someone help me, please?
You cannot append items to a given list in parallel (at least not without locks/synchronizations/atomics). Using prange
will not magically make your code faster. You need to be sure the code can be parallelized. If this is not possible, then the resulting code is ill-formed and results in an undefined behavior (for example a crash like the one you have).
If you want a fast code, use Numpy arrays, pre-allocate an array of the final size (or possibly bigger) and use direct assignments.