On 2009-05-19, Steven D'Aprano <ste...@remove.this.cybersource.com.au> wrote: > On Mon, 18 May 2009 02:27:06 -0700, jeremy wrote: > >> Let me clarify what I think par, pmap, pfilter and preduce would mean >> and how they would be implemented. > [...] > > Just for fun, I've implemented a parallel-map function, and done a couple > of tests. Comments, criticism and improvements welcome!
My only comment would be that your "slow function" might not be a very simulation for the general-case, since it uses time.sleep() which releases the GIL: > def f(arg): # Simulate a slow function. > time.sleep(0.5) > return 3*arg-2 Any Python function that isn't calling a library function written in C that releases the GIL won't show any speedup will it? I don't have a multi-core machine to try it on, but what happens when you replace your "slow function" code with something that actually burns CPU using pure-Python code instead of blocking on a timer in the OS? -- Grant -- http://mail.python.org/mailman/listinfo/python-list