, I find the current behaviour surprising and would like to see a distinct_permutations function.
How do I start to submit a patch?
That said, the odds of it being accepted are slim.
There are many ways to write combinatoric functions
(Knuth has a whole book on the subject) and I don't
aspire to include multiple variants unless there are
strong motivating use cases.
In general, if someone wants to eliminate duplicates
from the population, they can do so easily with:
permutations(set(population), n)
The current design solves the most common use cases
and it has some nice properties such as:
* permutations is a subsequence of product
* no assumptions are made about the comparability
or orderability of members of the population
* len(list(permutations(range(n), r))) == n! / (n-r)!
just like you were taught in school
* it is fast
For more exotic needs, I think is appropriate to look
outside the standard library to more full-featured
combinatoric libraries (there are several listed at