[Python-ideas] Possible new itertool: comm()

Eric V. Smith eric at trueblade.com
Wed Jan 7 19:24:19 CET 2015

On 01/07/2015 01:20 PM, David Mertz wrote:
> Adding a itertools.comm() seems unnecessary, although adding it to the
> widely used more-itertools feels more reasonable.
> However, the problem with the functionality is that it assumes that the
> iterables given to it return pre-sorted values.  Which is fine it that
> assumption is satisfied, but one really can't know in advance of
> exhausting the iterators whether that will prove true.  The desired
> behavior in the absence of this pre-condition being satisfied is unclear
> to me.

itertools.groupby has the same requirement for a pre-sorted input iterator.

But I do agree that itertools isn't the best place in the stdlib for
common(). difflib seems reasonable to me, if it's added at all.


More information about the Python-ideas mailing list