Threaded for loop

John weekender_ny at yahoo.com
Sat Jan 13 23:49:53 EST 2007


Damn! That is bad news. So even if caclulate is independent for (i,j)
and
is computable on separate CPUs (parts of it are CPU bound, parts are IO
bound)
python cant take advantage of this?

Surprised,
--j

Paul Rubin wrote:
> "John" <weekender_ny at yahoo.com> writes:
> > I want to do something like this:
> >
> > for i = 1 in range(0,N):
> >  for j = 1 in range(0,N):
> >    D[i][j] = calculate(i,j)
> >
> > I would like to now do this using a fixed number of threads, say 10
> > threads. What is the easiest way to do the "parfor" in python?
>
> It won't help in terms of actual parallelism.  Python only lets one
> thread run at a time, even on a multi-cpu computer.




More information about the Python-list mailing list