Adding a Par construct to Python?
grante at visi.com
Tue May 19 12:52:04 CEST 2009
On 2009-05-19, Steven D'Aprano <steven at 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.
> 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?
More information about the Python-list