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

Guido van Rossum guido at python.org
Tue Jan 6 19:47:44 CET 2015


Folks, I realize I'm sounding a bit like Raymond here, but can you all
please find a different forum to discuss algorithms and coding problems and
pick each other's solutions apart? The focus on python-ideas should be to
quickly validate ideas for the language or the stdlib, not to discuss
arbitrary snippets of code.

On Tue, Jan 6, 2015 at 10:44 AM, Paul Moore <p.f.moore at gmail.com> wrote:

> On 6 January 2015 at 18:36, Antoine Pitrou <solipsis at pitrou.net> wrote:
> > On Tue, 6 Jan 2015 18:22:44 +0000
> > Paul Moore <p.f.moore at gmail.com> wrote:
> >> On 6 January 2015 at 17:14, Raymond Hettinger
> >> <raymond.hettinger at gmail.com> wrote:
> >> >> On Jan 6, 2015, at 8:22 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> >> >>
> >> >> In writing a utility script today, I found myself needing to do
> >> >> something similar to what the Unix "comm" utility does - take two
> >> >> sorted iterators, and partition the values into "only in the first",
> >> >> "only in the second", and "in both" groups.
> >> >
> >> > As far as I can tell, this would be a very rare need.
> >>
> >> It's come up for me a few times, usually when trying to check two
> >> lists of files to see which ones have been missed by a program, and
> >> which ones the program thinks are present but no longer exist.
> >
> > Why don't you use sets for such things? Your iterator is really only
> > useful for huge or unhashable inputs.
>
> For the case described you're right. I had a case the other day where
> one of the problems was that one list had duplicates, and I needed to
> see that ([1,1,2,2] vs [1,2] needed to show [1,2] as "only in the
> first list" and [1,2] as "in both"). I could probably have used
> counters. But I was starting from thinking that I had a pair of sorted
> lists, and "in the Unix shell I'd use comm"...)
>
> Paul
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150106/31919aea/attachment.html>


More information about the Python-ideas mailing list