Parallelization on muli-CPU hardware?

exarkun at divmod.com exarkun at divmod.com
Tue Oct 12 09:50:03 EDT 2004


On Tue, 12 Oct 2004 15:08:46 +0200, "Nicolas Lehuen" <nicolas.lehuen at thecrmcompany.com> wrote:
> [snip]
> 
> Yeah I know this. My point was that when benchmarking single-threaded
> programs vs multithreaded ones, you have to choose the kind of program
> you use : CPU-intensive vs IO-intensive. On a single CPU machine,
> CPU-intensive program will always run better in a single-threaded model.
> But of course, if you have 2 procs and a nice threading model, you can
> even do 2 CPU-intensive tasks simultaneously, which Python cannot do if
> I've understood everything so far.

  The way to do this is to write an extension module, implement your CPU-intensive tasks, and release the GIL around it.  You can argue that this is not "in Python", but it is possible, widely practiced, supported by the language, developer community, and existing APIs, and lets you adjust Python's threading behavior _specific to your application_, rather than requiring every Python program written by every Python programmer comply with your wishes for the language.

  Jp



More information about the Python-list mailing list