What to use Multiprocessing or multi

This question already has an answer here:

  • Multiprocessing vs Threading Python 7 answers

  • It heavily depends on the type of analysis. Here is a simple rule of thumb to give hints:

  • if the process is memory bound, keep it serial
  • if it is io bound, use multithreading - optimal number of threads depends on the percentage of time spent in io waiting
  • if it is cpu-bound, use muti-processing with a number or process equal to the number of available cores
  • If you cannot be sure a priori, just experiment... But never forget that no method is absolutely better that the others in all possible use cases


    Maybe this is what you're looking for. https://nathangrigg.com/2015/04/python-threading-vs-processes

    possible answer

    Do you also need a brief description of these two & differences?

    To be short, if one of your sub-problems has to wait another finishes, Multi Thread is good (for example, I/O heavy operations); by contrast, if your sub-problems could really happen at the same time, Multi Processing is suggested. However, you won't create more processes than your number of cores. maybe this will explain you better

    链接地址: http://www.djcxy.com/p/55196.html

    上一篇: 试验线程和多处理模块,python

    下一篇: 什么使用多处理或多