Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <a href="http://docs.python.org/library/multiprocessing.html" rel="noreferrer">python documentation for multiprocessing</a> blames the lack of os.fork() for the problems in Windows. It may be applicable here.</p> <p>See what happens when you import psyco. First, easy_install it:</p> <pre><code>C:\Users\hughdbrown&gt;\Python26\scripts\easy_install.exe psyco Searching for psyco Best match: psyco 1.6 Adding psyco 1.6 to easy-install.pth file Using c:\python26\lib\site-packages Processing dependencies for psyco Finished processing dependencies for psyco </code></pre> <p>Add this to the top of your python script:</p> <pre><code>import psyco psyco.full() </code></pre> <p>I get these results without:</p> <pre><code>serialrun took 1191.000 ms parallelrun took 3738.000 ms threadedrun took 2728.000 ms </code></pre> <p>I get these results with:</p> <pre><code>serialrun took 43.000 ms parallelrun took 3650.000 ms threadedrun took 265.000 ms </code></pre> <p>Parallel is still slow, but the others burn rubber.</p> <p>Edit: also, try it with the multiprocessing pool. (This is my first time trying this and it is so fast, I figure I must be missing something.)</p> <pre><code>@print_timing def parallelpoolrun(reps): pool = multiprocessing.Pool(processes=4) result = pool.apply_async(counter, (reps,)) </code></pre> <p>Results:</p> <pre><code>C:\Users\hughdbrown\Documents\python\StackOverflow&gt;python 1289813.py serialrun took 57.000 ms parallelrun took 3716.000 ms parallelpoolrun took 128.000 ms threadedrun took 58.000 ms </code></pre>
    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. 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.
 

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