<div dir="auto"><div>Oh, it looks like he has modified the PEP and taken out the examples of conversion. That's too bad, hopefully they'll be added back.</div><div dir="auto"><br></div><div dir="auto">But it's pretty simple. Whether my idea of collections.Grouping is adapted or whether a function/classmethod grouping() produces a plain dictionary, the casting would be the same:</div><div dir="auto"><br></div><div dir="auto">{k:set(v) for k,v in deps.items()}</div><div dir="auto"><br></div><div dir="auto"><span style="font-family:sans-serif">{k:Counter(v) for k,v in deps.items()}</span><br></div><div dir="auto"><br></div><div dir="auto"><br><br><div class="gmail_quote" dir="auto"><div dir="ltr">On Sun, Jul 1, 2018, 10:12 PM David Mertz <<a href="mailto:mertz@gnosis.cx">mertz@gnosis.cx</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Michael changed from set to list at my urging. A list is more general. A groupby in Pandas or SQL does not enforce uniqueness, but DOES preserve order. I think the PEP is not fully updated, but it's a list everywhere in the proposal itself, just not in the "old techniques."</div><div dir="auto"><br></div><div dir="auto">Moreover,  Michael gives example of "casting" the Grouping to a dictionary with either sets or Counters as values. Both are useful, and both can be derived from list. But you cannot go backwards from either to the list. The transformation is simple and obvious, and can be included in eventual documentation.</div><div dir="auto"><br></div><div dir="auto">It really is better to construct the collection using lists—in the fully general manner—and then only throw away the generality when that appropriate.<br><br><div class="gmail_quote" dir="auto"><div dir="ltr">On Sun, Jul 1, 2018, 8:47 PM Chris Barker via Python-ideas <<a href="mailto:python-ideas@python.org" target="_blank" rel="noreferrer">python-ideas@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_quote"><br><div dir="ltr"><div>Ivan,<br><br></div>Did you mean this to go to the list? I hope so, as I've cc-d it this time :-)<br><div><div><div class="gmail_extra"><br><div class="gmail_quote"><span>On Sun, Jul 1, 2018 at 1:20 AM, Ivan Levkivskyi <span dir="ltr"><<a href="mailto:levkivskyi@gmail.com" rel="noreferrer noreferrer" target="_blank">levkivskyi@gmail.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><span>On 1 July 2018 at 06:18, Chris Barker via Python-ideas <span dir="ltr"><<a href="mailto:python-ideas@python.org" rel="noreferrer noreferrer" target="_blank">python-ideas@python.org</a>></span> wrote:<br></span><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div class="gmail_extra"><div class="gmail_quote"><span></span>I'm really warming to the:<div><br></div>Alternate: <span style="font-family:monospace,monospace">collections.Grouping</span></div><div class="gmail_quote"><br></div><div class="gmail_quote">version -- I really like this as a kind of custom mapping, rather than "just a function" (or alternate constructor) -- </div></div></div></div></div></div></div></blockquote></span></span></div></div></div></blockquote><div><br></div><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span></span>I wanted the group to be represented as a set, not a list. I however understand that list may be more common. Can we design an API that<div>would make this configurable? Something like:</div><div><br></div><div>    from collections import Grouping</div><div><br></div><div>    deps = Grouping(set)  # list can be the default</div><div>    deps.update(other_deps)  # uses set.update or list.extend for every key</div><div>    deps.add(trigger, target)  # uses set.add or list.append</div></div></div></div></blockquote><div><br></div></span><div>yeah, I thought about that too -- Michael was using set() in some of his examples.<br><br></div><div>But the question is -- do we have a single switchable version or just too classes?<br> </div><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Probably allowing an arbitrary collection for values is to general/hard. </div></div></div></div></blockquote><div><br></div></span><div>maybe not -- if we had the criteria that you pass in any collection you wanted, as long as it had either an <span style="font-family:monospace,monospace">.append()</span> or <span style="font-family:monospace,monospace">.add()</span>method, it would be pretty easy to do with duck typing magic.<span style="font-family:monospace,monospace"><br><br></span></div><div>Sure -- a user could make a mess easily enough by passing in a weird custom class, but so what? Using something other than a set or list would be a "at your own risk" thing anyway.<span style="font-family:monospace,monospace"></span><br> </div><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Maybe we can just add a flag `unique=True` to the constructor, that will cause using sets instead of lists for groups?</div></div></div></div></blockquote><div><br></div></span><div>That's another, more robust, but less flexible option.<br><br></div><div>Stay tuned for a prototype, if I can get it done fast....<br><br></div><div>-CHB<br><br></div></div><span><br>-- <br><div class="m_3790862910577997818m_-1292311888186430883m_-3810725848726083201gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" rel="noreferrer noreferrer" target="_blank">Chris.Barker@noaa.gov</a></div>
</span></div></div></div></div>
</div><br><br clear="all"><br>-- <br><div class="m_3790862910577997818m_-1292311888186430883gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" rel="noreferrer noreferrer" target="_blank">Chris.Barker@noaa.gov</a></div>
</div>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" rel="noreferrer noreferrer" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer noreferrer noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div></div></div>
</blockquote></div></div></div>