Xristos Xristoou <saxr...@gmail.com> writes:

> i have create an image processing python function.
>
> my system have 4 cores + 4 threads.
>
> i want to use multiprocessing to speed up my function,but anytime to
> use multiprocessing packages my function is not faster and is 1 minute
> slowly. any idea why ?first time use multiprocessing packages.
>
> main function :
>
> if __name__ == '__main__':
>     in_path="C:/Users/username/Desktop/in.tif"
>     out_path="C:/Users/username/Desktop/out.tif"
>     myfun(in_path, out_path)
> time=3.4 minutes
>
> with multiprocessing map :
>
> if __name__ == '__main__':
>     p = Pool(processes=4)
>     in_path="C:/Users/username/Desktop/in.tif"
>     out_path="C:/Users/username/Desktop/out.tif"
>     result = p.map(myfun(in_path,out_path))

Don't you get an error telling you that map needs another argument?

map is intended to be used like this:

  p.map(f, [1, 2, 3])

the function is applied to the elements drawn from the iterable second
argument.  Each application runs in a separate process form the pool and
the results are combined together into a list result.

So you could process multiple file in parallel using this method but it
can't run your function on that one input file in parallel.

<snip>
-- 
Ben.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to