title: How to do parallel programming in Python?
body: <p>For C++, we can use OpenMP to do parallel programming; however, OpenMP will not work for Python. What should I do if I want to parallel some parts of my python program?</p>
  <p>The structure of the code may be considered as:</p>
  <pre><code>solve1(A)
  solve2(B)
  </code></pre>
  <p>Where <code>solve1</code> and <code>solve2</code> are two independent function. How to run this kind of code in parallel instead of in sequence in order to reduce the running time?
  The code is:</p>
  <pre><code>def solve(Q, G, n):
      i = 0
      tol = 10 ** -4
  
      while i &lt; 1000:
          inneropt, partition, x = setinner(Q, G, n)
          outeropt = setouter(Q, G, n)
  
          if (outeropt - inneropt) / (1 + abs(outeropt) + abs(inneropt)) &lt; tol:
              break
              
          node1 = partition[0]
          node2 = partition[1]
      
          G = updateGraph(G, node1, node2)
  
          if i == 999:
              print &quot;Maximum iteration reaches&quot;
      print inneropt
  </code></pre>
  <p>Where <code>setinner</code> and <code>setouter</code> are two independent functions. That's where I want to parallel...</p>