Python itertools.product freezes with higher numbers
<p>I have 6 variables with different ranges. I want to create possibilities pool with my code. In this example i gave 10 range for every variable but i have to give them about 200 range. But whenever i'm trying to exceed 20 range (for example 30 range) Python kills itself, and sometimes it freezes computer. Is there anyway to make it faster and stable?</p>

<p>Thanks.</p>

<pre><code>import itertools

a = [x for x in range(400,411)]
b = [x for x in range(400,411)]
c = [x for x in range(400,411)]
d = [x for x in range(400,411)]
e = [x for x in range(400,411)]
f = [x for x in range(400,411)]

fl = lambda x: x

it = filter(fl, itertools.product(a,b,c,d,e,f))

posslist = [x for x in it]

print(len(posslist))
</code></pre>

<p>Thanks everyone for your answers. While searching for a better solution, i found an answer on Python documentation. There is an example on documentation for using itertools.product as generator instead of list. Yet, i still can't find any good idea to make it faster. This will help you too if your going to use product with high values.
<br>
<br><a href="https://docs.python.org/2.7/library/itertools.html#itertools.product" rel="nofollow">Product generator for Python 2</a>
<br><a href="https://docs.python.org/3.5/library/itertools.html#itertools.product" rel="nofollow" title="Python 3 product generator">Product generator for Python 3</a></p>

python python-3.x itertools