eventlet引发的学习-python如何利用多核CPU

来源:互联网 发布:java iterator 将int 编辑:程序博客网 时间:2024/05/21 03:19

背景

通过前面几篇文章,已经清楚由于Python GIL的存在,python多线程无法达到并行执行的效果,从而也就无法达到充分利用多核CPU的效果。

解决方案

那有在python中有哪些方式才能充分利用多核CPU达到并行执行的效果呢?

  • 使用[multiprocessing],(http://docs.python.org/library/multiprocessing.html)(多进程),可以使代码同时运行在多个进程中。
  • 使用Jython解释器/运行时环境
  • 使用IronPython解释器/运行时环境
  • 使用subprocess
  • 使用celery
  • 使用mpicpy
  • 使用Twisted
  • 使用Ampoule
  • 使用numpy
  • 使用ctypes

参考

Is python capable of running on multiple cores

Does python support multiprocessor/multicore programming?

0 0