[Python-ideas] Extremely weird itertools.permutations

Neil Girdhar mistersheik at gmail.com
Sun Oct 13 09:38:40 CEST 2013


My intuition is that we want Python to be "complete".  Many other languages
can find the permutations of a multiset.  Python has a permutations
function.  Many people on stackoverflow expected that function to be able
to find those permutations.

One suggestion: Why not make it so that itertools.permutations checks if
its argument is an instance of collections.Mapping?  If it is, we could
interpret the items as a mapping from elements to positive integers, which
is a compact representation of a multiset.  Then, it could do the right
thing for that case.

Best,
Neil




On Sat, Oct 12, 2013 at 11:03 PM, Raymond Hettinger <
raymond.hettinger at gmail.com> wrote:

>
> On Oct 12, 2013, at 6:47 PM, Steven D'Aprano <steve at pearwood.info> wrote:
>
> the proposal is not to eliminate duplicates from
> the population, but from the permutations themselves.
>
>
> I'm curious about the use cases for this.
> Other than red/blue marble examples and some puzzle problems,
> does this come-up in any real problems?  Do we actually need this?
>
>
> Raymond
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python-ideas/dDttJfkyu2k/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131013/25d072e2/attachment.html>


More information about the Python-ideas mailing list