Multiprocessing or Multithreading?

前端 未结 9 564
夕颜
夕颜 2020-12-12 16:13

I\'m making a program for running simulations in Python, with a wxPython interface. In the program, you can create a simulation, and the program renders (=calculates) it for

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-12 16:59

    Very puzzled. Bastien Léonard rightly pointed out that the GIL will stop any ability to use threading in any useful way. His reference states:

    "Use of a global interpreter lock in a language effectively limits the amount of parallelism reachable through concurrency of a single interpreter process with multiple threads. If the process is almost purely made up of interpreted code and does not make calls outside of the interpreter for long periods of time (which can release the lock on the GIL on that thread while it processes), there is likely to be very little increase in speed when running the process on a multiprocessor machine. Due to signaling with a CPU-bound thread, it can cause a significant slowdown, even on single processors."

    This being the case, multi-processing is then the sensible choice. From my own experience Python + MT is of no noticeable benefit to the user.

提交回复
热议问题