'I need permutations between multiple lists and i need it to be done fastest and most efficient way possible

I have multiple lists of numbers like these:

a = np.arange(100,150,1).tolist()
b = np.arange(300,330,1).tolist()
c = np.arange(600,900,1).tolist()
d = np.arange(1250,1400,1).tolist()

i need permutations between these lists with specific length (my ultimate goal is to choose the one permutation that satisfy my conditions such as distance between each number in permutation), for example if length is 3 i want : (100,300,600) and ... and if length is 2 i want (100,300) and ... i used itertools but my computer crashed everytime , is there an efficient way to do it? or do i need some kind of algorithm to do it faster and not calculate all possible permutations ?

thank you



Solution 1:[1]

I would say to use a process pool executor.

If you are running out of memory, then maybe it would be better to use workers and a queue or deque.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 oda