Does running separate python processes avoid the GIL?

后端 未结 2 1757
情深已故
情深已故 2021-01-03 22:59

I\'m curious in how the Global Interpreter Lock in python actually works. If I have a c++ application launch four separate instances of a python script will they run in para

相关标签:
2条回答
  • 2021-01-03 23:51

    As Alex Martelli points out you can indeed avoid the GIL by running multiple processes, I just want to add and point out that the GIL is a limitation of the implementation (CPython) and not of Python in general, it's possible to implement Python without this limitation. Stackless Python comes to mind.

    0 讨论(0)
  • 2021-01-03 23:53

    The GIL only affects threads within a single process. The multiprocessing module is in fact an alternative to threading that lets Python programs use multiple cores &c. Your scenario will easily allow use of multiple cores, too.

    0 讨论(0)
提交回复
热议问题