0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

並列処理学習6-本当の意味での並列性

Posted at

Pythonで、CPUを複数使用した複数スレッドによる実装を行うために用意されているのものがある。
それが、concurrent.futuresから利用できるmultiprocessingモジュール。

複数CPUでの処理が可能となり、子プロセスを並列処理として扱うことが出来る。
GILは、プロセスごとに適用されるため、CPUの利用を完全に個別に扱うことが可能となる。
プロセスはリンクを持つので、データの受け渡しも可能。

concurrent.futures

multiprocessingを拡張し、扱いやすくしたモジュール。
multiprocessingのみ使用しようとすると、とても複雑な処理を行う必要がある。

特別理由がなければ、concurrent.futuresのThreadPoolExecutorを利用すると良い。
速度向上を求めたいのであれば、ProcessPoolExecutorの利用も検討する。
上記の判断は、処理の分離具合と、やりとりするデータ量を鑑みて判断するのが良い。

どうしてもさらなる高速化が必要ならば、multiprocessingモジュールを利用を検討する。

まにゅある

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?