Parallelize these nested for loops in python
<p>I have a multidimensional array (<code>result</code>) that should be filled by some nested loops. Function <code>fun()</code> is a complex and time-consuming function. I want to fill my array elements in a parallel manner, so I can use all my system's processing power.
Here's the code:</p>

<pre><code>import numpy as np


def fun(x, y, z):
    # time-consuming computation...
    # ...

    return output


dim1 = 10
dim2 = 20
dim3 = 30

result = np.zeros([dim1, dim2, dim3])

for i in xrange(dim1):
    for j in xrange(dim2):
        for k in xrange(dim3):
            result[i, j, k] = fun(i, j, k)
</code></pre>

<p>My question is that "Can I parallelize this code or not? if yes, How?"</p>

<p>I'm using Windows 10 64-bit and python 2.7.</p>

<p>Please provide your solution by changing my code if you can.
Thanks!</p>