Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From my experience, multi-threading is probably not going to be a viable option for speeding things up (due to the <a href="http://en.wikipedia.org/wiki/Global_Interpreter_Lock" rel="noreferrer">Global Interpreter Lock</a>).</p> <p>A good alternative is the <a href="http://docs.python.org/library/multiprocessing.html" rel="noreferrer"><code>multiprocessing</code></a> module. This may or may not work well, depending on how much data you end up having to pass around from one process to another.</p> <p>Another good alternative would be to consider using <a href="http://numpy.scipy.org/" rel="noreferrer"><code>numpy</code></a> for your computations (if you aren't already). If you can vectorize your code, you should be able to achieve significant speedups even on a single core. Depending on what exactly you're doing and on your build of <code>numpy</code>, it might even be able to transparently distribute the computations across multiple cores.</p> <p><strong>edit</strong> Here is a complete example of using the <code>multiprocessing</code> module to perform a simple computation. It uses four processes to compute the squares of the numbers from zero to nine.</p> <pre><code>from multiprocessing import Pool def f(x): return x*x if __name__ == '__main__': pool = Pool(processes=4) # start 4 worker processes inputs = range(10) result = pool.map(f, inputs) print result </code></pre> <p>This is meant as a simple illustration. Given the trivial nature of <code>f()</code>, this parallel version will almost certainly be slower than computing the same thing serially.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload