I was curious to know how much you can increase productivity, so I wrote a new function for gmpy2 , which calculated the entire list sin in C. Unfortunately, there was no improvement.
%timeit [gmpy2.sin(x) for x in a] 100 loops, best of 3: 4.85 ms per loop %timeit map(gmpy2.sin, a) 100 loops, best of 3: 4.59 ms per loop %timeit gmpy2.vector(a) 100 loops, best of 3: 4.44 ms per loop
gmpy2 does not release Global Interpreter Lock (GIL), so the thread will not help.
Multiprocessing can help, but you may have to parallelize parts of the code that take seconds (or more) to execute in order to overcome the overhead of transferring data to another process.
A software-based floating point of arbitrary precision is only slower than a native floating point.
source share