Multithreading performance overhead

前端 未结 2 635
误落风尘
误落风尘 2020-12-19 21:38

So basically I created this program that adds values to redis. So far I get this timing:

real 0m27.759s
user 0m18.12         


        
相关标签:
2条回答
  • 2020-12-19 22:24

    The result depends on the Python implementation, cpython's GIL prevents parallel computations from being faster than sequential ones.

    Consider using the multiprocessing module, which executes each thread in its own Python process, or alternative GIL-free Python implementations like IronPython and Jython.

    0 讨论(0)
  • 2020-12-19 22:36

    You can use Parallel Python for this.

    Here is an example of parallel sum:

    http://www.parallelpython.com/content/view/17/31/#SUM_PRIMES

    0 讨论(0)
提交回复
热议问题