One of the nice features of capabilities provided in the standard library is a set of
data types together with a set of algorithms that that work consistently with them.
For example, we have sequence types that can be used with the itertools module where
combinations, combinations_with_replacement, permutations and product are all available.
Being a part of the standard library, these facilities are implemented consistently
and their widespread use means that we can have great deal of confidence in their
efficiency, effectiveness, reliability and correctness. In short, we can trust them.
Maybe I am on my own here but I make a lot of use of multisets and find that this data
type is not well catered for in the Python universe.
There is the counter class in the standard library but it is not a full multiset
implementation; there is also a full implementation on PyPy but there are no 'itertools
equivalent' algorithms that are designed to work with it. As a result, I am often
driven to use, for example, itertools set(permutations(multiset, n)) which is typically
very inefficient when compared with a properly implemented multiset permutation algorithm.
And, although there are implementations of various multiset 'itertools algorithms' around,
these are 'one-off' pieces of code put together by 'people who needed them' and in which
there is little if any solid evidence that they do what they claim to do (some I have tried
certainly don't!).
So my plea is for a multiset implementation in the Python standard library (combined witn its
itertools equivalent combinatorial algorithms). Being a part of the standard library will
bring implementation consistency and widespread use over time will bring us reliability,
efficiency, effectiveness and trustworthiness.
Brian Gladman