While trying to speed up:
l = some_value
for i in range(1000):
for j in range(1000):
for k in range(1000):
function(i, j, k, l)
I stumbled upon multiprocessing.Pool().starmap()
however it requires the iterated values to be passed in as an interator [(0, 0, 0), (1, 0, 0), ...]
. Is there a fast way to get this list of tuples containing the for loop values?
CodePudding user response:
Here's an iterator you need:
iterator = ((i, j, k, l) for i in range(1000)
for j in range(1000)
for k in range(1000))