is python capable of running on multiple cores?

前端 未结 7 1049
悲&欢浪女
悲&欢浪女 2020-11-28 03:58

Question: Because of python\'s use of \"GIL\" is python capable running its separate threads simultaneously?


Info:

After reading this I came away rathe

7条回答
  •  感动是毒
    2020-11-28 04:30

    CPython (the classic and prevalent implementation of Python) can't have more than one thread executing Python bytecode at the same time. This means compute-bound programs will only use one core. I/O operations and computing happening inside C extensions (such as numpy) can operate simultaneously.

    Other implementation of Python (such as Jython or PyPy) may behave differently, I'm less clear on their details.

    The usual recommendation is to use many processes rather than many threads.

提交回复
热议问题