[SciPy-User] all unique permutations

josef.pktd at gmail.com josef.pktd at gmail.com
Thu Apr 28 21:49:10 EDT 2011


On Thu, Apr 28, 2011 at 9:25 PM, Alan G Isaac <alan.isaac at gmail.com> wrote:
> On 4/28/2011 9:12 PM, josef.pktd at gmail.com wrote:
>> I didn't find any iterator that would give unique values
>
> It's true that itertools.permutations is  based on index
> permutations, but when the number of permuations is not
> huge, it is pretty cheap to form a set or a Counter.

But it won't be an iterator anymore, and we need the entire set at once.

I would like to go for big, maybe not huge, (and I'm still missing
several other pieces and I still don't have an efficient code.)  The
target are exact permutation tests where the number of permutations
grows very fast, (some papers by Mielke that I don't find right now.)

>>> len(list(itertools.permutations([0,0,0,0,0,1,1,1,1])))
362880
>>> len(list(permit([0,0,0,0,0,1,1,1,1])))
126
>>>
>>> len(list(permit([0,0,0,0,0,1,1,1,1,1,1])))
462
>>> len(list(itertools.permutations([0,0,0,0,0,1,1,1,1,1,1])))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
MemoryError
>>>

it stopped at around 1.5 gigabyte according to taskmanager

Josef


>
> fwiw,
> Alan
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list