开发者

What is more suitable in performance aspect - Multithreading or Multiprocessing?

开发者 https://www.devze.com 2023-03-28 03:27 出处:网络
I would like to run several receivers that will receive data in different ports, but are basically the same.

I would like to run several receivers that will receive data in different ports, but are basically the same. What is more suitable in performance aspect - Multithreading开发者_JAVA技巧 or Multiprocessing?


The trouble with Python is that the most common interpreters contain a global lock -- commonly known as the GIL. This means that only one thread can execute python code at once, so a multi-process model can often make more efficient use of multiple cores than a multi-thread model.


If the application is I/O-bound, threading will suffice (and be faster).

If it's CPU-bound, and you're using cpython or another Python interpreter with a GIL, multiprocessing is the right choice instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消