On 10/12/2013 3:35 AM, Steven D'Aprano wrote:
I'd even turn this around and challenge you to find a source that *does* define them as always unique. Here's a typical example, from the Collins Dictionary of Mathematics:
[quote] **permutation** or **ordered arrangement** n. 1 an ordered arrangement of a specified number of objects selected from a set. The number of distinct permutations of r objects from n is
n!/(n-r)!
usually written <subscript>n P <subscript>r or <superscript>n P <subscript>r. For example there are six distinct permutations of two objects selected out of three: <1,2>, <1,3>, <2,1>, <2,3>, <3,1>, <3,2>. Compare COMBINATION.
The items of a set are, by definition of a set, distinct, so the question of different but equal permutations does not arise.
2. any rearrangement of all the elements of a finite sequence, such as (1,3,2) and (3,1,2). It is *odd* or *even* according as the number of exchanges of position yielding it from the original order is odd or even. It is a *cyclic permutation* if it merely advances all the elements a fixed number of places; that is, if it is a CYCLE of maximal LENGTH. A *transposition* is a cycle of degree two, and all permutations factor as products of transpositions. See also SIGNATURE.
The items of a sequence may be duplicates. But in the treatments of permutations I have seen (admittedly not all of them), they are considered to be distinguished by position, so that one may replace the item by counts 1 to n and vice versa.
3. any BIJECTION of a set to itself, where the set may be finite or infinite. [end quote]
Back to a set of distinct items again. You are correct that itertools.permutations does the right thing by standard definition.
Last but not least, here's a source which clearly distinguishes permutations from "permutations with duplicates":
http://mathcentral.uregina.ca/QQ/database/QQ.09.07/h/beth3.html
and even gives a distinct formula for calculating the number of permutations. Neither Wolfram Mathworld nor the Collins Dictionary of Maths consider this formula important enough to mention, which suggests strongly that it should be considered separate from the default permutations.
The question is whether this particular variation is important inportant enough to put in itertools. It is not a combinatorics module and did not start with permutations. -- Terry Jan Reedy