is python capable of running on multiple cores?

前端 未结 7 1047
悲&欢浪女
悲&欢浪女 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:24

    Python threads cannot take advantage of many cores. This is due to an internal implementation detail called the GIL (global interpreter lock) in the C implementation of python (cPython) which is almost certainly what you use.

    The workaround is the multiprocessing module http://www.python.org/dev/peps/pep-0371/ which was developed for this purpose.

    Documentation: http://docs.python.org/library/multiprocessing.html

    (Or use a parallel language.)

提交回复
热议问题