3 ms·
Here's a link: https://scipy-cookbook.readthedocs.io/items/ParallelProgramming.html https://scipy-cookbook.readthedocs.io/items/ParallelProgramm... And a quote
by aspaceman 7y ago
Here's a link: https://scipy-cookbook.readthedocs.io/items/ParallelProgramming.html https://scipy-cookbook.readthedocs.io/items/ParallelProgramm... And a quote in italics below.
And, more importantly for us, while numpy is doing an array operation, python also releases the GIL. Thus if you tell one thread to do:
print "%s %s %s %s and %s" %( ("spam",) *3 + ("eggs",) + ("spam",) )
A = B + C
print A
During the print operations and the % formatting operation, no other thread can execute. But during the A = B + C, another thread can run - and if you've written your code in a numpy style, much of the calculation will be done in a few array operations like A = B + C. Thus you can actually get a speedup from using multiple threads.