deciding among subprocess, multiprocessing, and thread in Python?

后端 未结 5 854
感情败类
感情败类 2020-11-29 15:10

I\'d like to parallelize my Python program so that it can make use of multiple processors on the machine that it runs on. My parallelization is very simple, in that all the

5条回答
  •  感动是毒
    2020-11-29 15:22

    To use multiple processors in CPython your only choice is the multiprocessing module. CPython keeps a lock on it's internals (the GIL) which prevents threads on other cpus to work in parallel. The multiprocessing module creates new processes ( like subprocess ) and manages communication between them.

提交回复
热议问题