@leo2k This sounds more like a process bottleneck. Recommend the usage of multiprocessing pool to speed up
https://docs.python.org/3/library/multiprocessing.html
if you are up for adventure, you can use the cuda cores to do this calculation. This will be blazing fast
  
      

      GeeksforGeeks – 21 Aug 19
  

  
    

Running Python script on GPU. - GeeksforGeeks 2

  A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.