from itertools import combinations, count, takewhile
n=25
t=12
chunk_size = 10000
x = combinations(range(n),t)
i = 0
while True:
l = [*takewhile(lambda _, c=count(): next(c) < chunk_size, x)]
# your code here, l is a list of length max. 10000 of combinations
print(l)
i += 1
if len(l) < chunk_size:
break
print('We have done {} iterations.'.format(i))
Отпечатки:
[(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 16), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 17), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 18), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 19), ...
И в конце:
We have done 520 iterations.