I'm now convinced that itertools.permutations is fine as it is. I am not totally convinced that multiset_permutations doesn't belong in itertools,
Now that we have a good algorithm, I'm open to adding this to itertools,
but it would need to have a name that didn't create any confusion
with respect to the existing tools, perhaps something like:
anagrams(population, r)
Return an iterator over a all distinct r-length permutations
of the population.
Unlike permutations(), element uniqueness is determined
by value rather than by position. Also, anagrams() makes
no guarantees about the order the tuples are generated.
Raymond