[Python-ideas] Include partitioning in itertools

Albert ten Oever agtoever at hotmail.com
Tue Nov 3 10:46:41 EST 2015


> [Sven R. Kunze]
> > ...
> > Not quite sure if I understand the implementation. Reading this
> > http://mathworld.wolfram.com/BellNumber.html for the given example of 6, it
> > should have 203 possible partitions. What am I missing?
> > [Tim Peters]
> The ActiveState recipe has nothing to do with set partitions.  Instead
> it returns all ways of breaking a sequence into a sequence of
> subsequences whose sum (catenation) is the original sequence.  If
> there are N elements in the original sequence, there are 2**(N-1) ways
> to do that.  That's why there are 32 results in the recipe's example
> output (2**(len("abcdef")-1) == 32).  There would be 203 "set
> partitions" of a 6-element set.

@Tim: you are completely right. Sorry for the confusion referencing this implementation. Forget it.

> On Sun, Nov 1, 2015 at 6:37 PM, Brendan Barnwell <brenbarn at brenbarn.net> wrote:
> > On 2015-11-01 17:58, David Mertz wrote:
> >> Oh, yeah... I see what you are asking for isn't quite the same thing as
> >> power set.  But still, it's not something you can do in finite time with
> >> infinite iterators (nor in tractable time with *large* iterators).  So
> >> `itertools` isn't where it belongs.
> >>
> >
> >         I don't think that reasoning is sound.  Itertools already includes
> > several combinatoric generators like permutations and combinations, which
> > aren't computable for infinite iterators and which take intractable time
> > for large finite iterators.
> >

@Brendan: exactly! 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151103/4dad6c4a/attachment.html>


More information about the Python-ideas mailing list