How to use C extensions in python to get around GIL

后端 未结 5 1203
走了就别回头了
走了就别回头了 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:14

    Have you considered using one of the python mpi libraries like mpi4py? Although MPI is normally used to distribute work across a cluster, it works quite well on a single multicore machine. The downside is that you'll have to refactor your code to use MPI's communication calls (which may be easy).

提交回复
热议问题