Hi Brian,

It sounds like a high quality third-party library that has both a multiset implementation and the itertools you needed would fulfill most of your requirements?

Code in the standard library isn't magically of higher quality. Compare eg standard library dataclasses with dataclassy.

As a matter of practicality, it might be best if you implemented your ideas as a normal library and after its been proven, you can then lobby for its inclusion in the standard library?

(I have only just started contributing to Python. So this is just my opinion. Nothing official.)

Cheers,
Matthias 


On Fri, 12 Aug 2022, 23:42 Brian Gladman, <riemannic@gmail.com> wrote:
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
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/N4EQCCIHL7CYYSODUWSTB4AKR4FM4YVJ/
Code of Conduct: http://python.org/psf/codeofconduct/