is python capable of running on multiple cores?

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

    I reproduce the code above and in parallel it was quicker.

    range(10000)
    Sequential run time: 228.56 seconds
    Parallel run time  : 147.03 seconds
    
    my hardware and software setup:
    Raspberry Pi 3 B+
    Raspbian v 4.19.57-v7+ #1244
    Python v. 3.5.3
    GCC v. 6.3
    

    During sequential process the CPU goes to 25% of utilization and during parallel process the CPU goes to 100%

    Update on Jan/2020; today I did a new test. This time using my laptop I ran the code above:

    range(1000000)
    Sequential run time: 36.698254108428955 seconds
    Parallel run time  : 25.329885959625244 seconds
    
    my hardware and software setup:
    W10
    i7-8565-U
    16 MB RAM
    SSD 256MB
    
    Python 3.8.1
    MSC v.1916 64 bit (AMD64)
    

提交回复
热议问题