[GRASS-user] "Parallelization" of Python Script
Hamish
hamish_b at yahoo.com
Tue Aug 7 02:02:43 PDT 2012
Daniel wrote:
> Although I would note that it's very possible to embed the previous type
> of loop into methods or functions if you wish. I normally write
> object-oriented though and have heard that the multiprocessing library can
> only be used with functions because it has trouble passing the objects
> (although maybe explicitly specifying self would take care of that problem,
> I've never tried it).
I'm not an expert, but fwiw another thing to consider is that the python
multiprocessing library has to do a trick to make each "thread", it actually
makes them as a much more expensive system process. the trouble is a basic
limitation/feature of python where everything in the interpreter has to run
in the same processor. so multi-processing in python inside a smaller loop
or with NumPy can be problematic; better to stick with high-level MP in
python I think.
there's a lot of FAQ and threads out there about the Python Global
Interpreter Lock (GIL) issue which is the reason for that.
Hamish
More information about the grass-user
mailing list