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