<p style="margin:0px 0px 0px 0px;font:8.0px Helvetica"><span class="Apple-style-span" style="font-family:arial;font-size:small">The multiprocessing module allows the programmer to fully leverage <b>multiple</b> processors on a given machine (python docs). This</span><span class="Apple-style-span" style="font-family:arial;font-size:small"> allows the operating system to take advantage of any parallelism inherent in the hardware design.</span></p>
<div><p></p></div><div>If you are using the module on non-multiprocessor machines, I think you are not using it to its full capability, and the module's overhead will just slow down your code.</div><div><br></div><div>
Aldrich</div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">On Thu, Jun 21, 2012 at 12:05 AM, Yesterday Paid <span dir="ltr"><<a href="mailto:howmuchistoday@gmail.com" target="_blank">howmuchistoday@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">from multiprocessing import Pool<br>
from itertools import product<br>
<br>
def sym(lst):<br>
    x,y=lst<br>
    tmp=x*y<br>
    if rec(tmp):<br>
        return tmp<br>
    else:<br>
        return None<br>
<br>
def rec(num):<br>
    num=str(num)<br>
    if num == "".join(reversed(num)):    return True<br>
    else:    return False<br>
<br>
if __name__ == "__main__":<br>
    pool=Pool(processes=8)<br>
    lst=product(xrange(100,1000),repeat=2)<br>
    rst=pool.map(sym,lst)<br>
    #rst=sym(lst)<br>
    print max(rst)<br>
<br>
<br>
in my old computer(2006),<br>
when run it on single process, it takes 2 seconds<br>
but using multiprocessing.pool, it takes almost 8 or 9 seconds<br>
is it possible?<br>
<span class="HOEnZb"><font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br>