How to use C extensions in python to get around GIL

后端 未结 5 1134
走了就别回头了
走了就别回头了 2021-02-19 23:51

I want to run a cpu intensive program in Python across multiple cores and am trying to figure out how to write C extensions to do this. Are there any code samples or tutorials

5条回答
  •  没有蜡笔的小新
    2021-02-20 00:20

    Take a look at multiprocessing. It's an often overlooked fact that not globally sharing data, and not cramming loads of threads into a single process is what operating systems prefer.

    If you still insist that your CPU intensive behaviour requires threading, take a look at the documentation for working with the GIL in C. It's quite informative.

提交回复
热议问题