Re: Parallelization in Python 2.6

2009-08-19 Thread Grant Edwards
On 2009-08-19, Stefan Behnel stefan...@behnel.de wrote: Dennis Lee Bieber wrote: If they are number crunchers (CPU-bound) and don't make use of binary extension libraries that release the GIL (for the most common Python implementation), they'll run faster being called in sequence since

Re: Parallelization in Python 2.6

2009-08-19 Thread Stefan Behnel
Dennis Lee Bieber wrote: On Tue, 18 Aug 2009 13:45:38 -0700 (PDT), Robert Dailey wrote: Really, all I'm trying to do is the most trivial type of parallelization. Take two functions, execute them in parallel. This type of parallelization is called embarrassingly parallel, and is the simplest

Re: Parallelization in Python 2.6

2009-08-19 Thread Hendrik van Rooyen
On Tuesday 18 August 2009 22:45:38 Robert Dailey wrote: Really, all I'm trying to do is the most trivial type of parallelization. Take two functions, execute them in parallel. This type of parallelization is called embarrassingly parallel, and is the simplest form. There are no dependencies

Re: Parallelization in Python 2.6

2009-08-19 Thread Paul Rubin
Hendrik van Rooyen hend...@microcorp.co.za writes: Just use thread then and thread.start_new_thread. It just works. The GIL doesn't apply to threads made like that?! -- http://mail.python.org/mailman/listinfo/python-list

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 18 Aug, 11:19, Robert Dailey rcdai...@gmail.com wrote: I'm looking for a way to parallelize my python script without using typical threading primitives. For example, C++ has pthreads and TBB to break things into tasks. In C++, parallelization without typical threading primitives usually

Re: Re: Parallelization in Python 2.6

2009-08-19 Thread Dave Angel
Hendrik van Rooyen wrote: On Tuesday 18 August 2009 22:45:38 Robert Dailey wrote: Really, all I'm trying to do is the most trivial type of parallelization. Take two functions, execute them in parallel. This type of parallelization is called embarrassingly parallel, and is the simplest form.

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 18 Aug, 13:45, Robert Dailey rcdai...@gmail.com wrote: Really, all I'm trying to do is the most trivial type of parallelization. Take two functions, execute them in parallel. This type of parallelization is called embarrassingly parallel, and is the simplest form. There are no dependencies

Re: Parallelization in Python 2.6

2009-08-19 Thread Martin P. Hellwig
sturlamolden wrote: cut The human brain is bad at detecting computational bottlenecks though. So it almost always pays off to write everything in Python first, and use the profiler to locate the worst offenders. +1 QOTW -- MPH http://blog.dcuktec.com 'If consumed, best digested with added

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 19 Aug, 05:16, sturlamolden sturlamol...@yahoo.no wrote: You should know about the GIL. It prevents multiple threads form using the Python interpreter simultaneously. For parallel computing, this is a blessing and a curse. Only C extensions can release the GIL; this includes I/0 routines

Re: Parallelization in Python 2.6

2009-08-19 Thread Hendrik van Rooyen
On Wednesday 19 August 2009 10:13:41 Paul Rubin wrote: Hendrik van Rooyen hend...@microcorp.co.za writes: Just use thread then and thread.start_new_thread. It just works. The GIL doesn't apply to threads made like that?! The GIL does apply - I was talking nonsense again. Misread the OP's

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 19 Aug, 05:27, Dave Angel da...@ieee.org wrote: With the current GIL implementation, for two CPU-bound tasks, you either do them sequentially, or make a separate process. I'd also like to add that most compute-bound code should be delegated to specialized C libraries, many of which are

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 19 Aug, 05:34, Hendrik van Rooyen hend...@microcorp.co.za wrote: The GIL does apply - I was talking nonsense again.  Misread the OP's intention. It depends on what the OP's functions doStuff1 and doStuff2 actually do. If they release the GIL (e.g. make I/O calls) it does not apply. The GIL

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 18 Aug, 11:41, Stefan Behnel stefan...@behnel.de wrote: I think the canonical answer is to use the threading module or (preferably) the multiprocessing module, which is new in Py2.6. http://docs.python.org/library/threading.htmlhttp://docs.python.org/library/multiprocessing.html Both

Re: Parallelization in Python 2.6

2009-08-19 Thread sturlamolden
On 19 Aug, 05:27, Dave Angel da...@ieee.org wrote: But if you do it that way, it's slower than sequential.  And if you have a multi-core processor, or two processors, or ...   then it gets much slower yet, and slows down other tasks as well. With the current GIL implementation, for two

Parallelization in Python 2.6

2009-08-18 Thread Robert Dailey
I'm looking for a way to parallelize my python script without using typical threading primitives. For example, C++ has pthreads and TBB to break things into tasks. I would like to see something like this for python. So, if I have a very linear script: doStuff1() doStuff2() I can parallelize it

Re: Parallelization in Python 2.6

2009-08-18 Thread Stefan Behnel
Robert Dailey wrote: I'm looking for a way to parallelize my python script without using typical threading primitives. For example, C++ has pthreads and TBB to break things into tasks. I would like to see something like this for python. So, if I have a very linear script: doStuff1()

Re: Parallelization in Python 2.6

2009-08-18 Thread Jonathan Gardner
On Aug 18, 11:19 am, Robert Dailey rcdai...@gmail.com wrote: I'm looking for a way to parallelize my python script without using typical threading primitives. For example, C++ has pthreads and TBB to break things into tasks. I would like to see something like this for python. So, if I have a

Re: Parallelization in Python 2.6

2009-08-18 Thread Robert Dailey
On Aug 18, 3:41 pm, Jonathan Gardner jgard...@jonathangardner.net wrote: On Aug 18, 11:19 am, Robert Dailey rcdai...@gmail.com wrote: I'm looking for a way to parallelize my python script without using typical threading primitives. For example, C++ has pthreads and TBB to break things