Memory error python computing permutations of list
<p>I want to compute all possible ways of constructing a binary list of length n with the following line</p>

<pre><code>combinations = map(list, itertools.product([0, 1], repeat=n))
</code></pre>

<p>This works fine with low n's but I want to compute this for big n's (i.e. values between 25-35). Is there a better and more efficient way of producing this list? </p>

<p>No, if you really want a list of lists then your code is almost as memory efficient as it could be. Your issue is the size of the list, not the way you are computing it.</p>

<p>Do you realize that for n=35 you will have 1,202,590,842,880 elements? Most (if not all) desktop computers can't hold so many python integers in memory.</p>

python python-2.7 permutation combinatorics