[Python-ideas] Extremely weird itertools.permutations

Andrew Barnert abarnert at yahoo.com
Sat Oct 12 10:22:59 CEST 2013


On Oct 11, 2013, at 23:55, Neil Girdhar <mistersheik at gmail.com> wrote:

> I think my best proposal is to have an efficient distinct_permutations function in itertools.  It should be in itertools so that it is discoverable.  It should be a function rather one of the recipes proposed to make it as efficient as possible.  (Correct me if I'm wrong, but like the set solution, groupby is also not so efficient.)
> 
> I welcome the discussion and hope that the most efficient implementation someone here comes up with will be added one day to itertools.

I think getting something onto PyPI (whether as part of more-itertools or elsewhere) and/or the ActiveState recipes (and maybe StackOverflow and CodeReview) is the best way to get from here to there. Continuing to discuss it here, you've only got the half dozen or so people who are on this list and haven't tuned out this thread to come up with the most efficient implementation. Put it out in the world and people will begin giving you comments/bug reports/rants calling you an idiot for missing the obvious more efficient way to do it, and then you can use their code. And then, when you're satisfied with it, you have a concrete proposal for something to add to itertools in python X.Y+1 instead of some implementation to be named later to add one day.

I was also going to suggest that you drop the argument about whether this is the one true definition of sequence permutation and just focus on whether it's a useful thing to have, but it looks like you're way ahead of me there, so never mind.


More information about the Python-ideas mailing list