Note that if permutations is made to return only unique permutations, the behaviour of defining unique elements by index can be recovered using:

([it[index] for index in indexes] for indexes in itertools.permutations(range(len(it))))

On Friday, October 11, 2013 2:38:33 PM UTC-4, Neil Girdhar wrote:
"It is universally agreed that a list of n distinct symbols has n! permutations. However, when the symbols are not distinct, the most common convention, in mathematics and elsewhere, seems to be to count only distinct permutations." — http://stackoverflow.com/questions/6534430/why-does-pythons-itertools-permutations-contain-duplicates-when-the-original.


Should we consider fixing itertools.permutations and to output only unique permutations (if possible, although I realize that would break code). It is completely non-obvious to have permutations returning duplicates. For a non-breaking compromise what about adding a flag?

Best,
Neil