<div dir="auto">I think that sequence should be fixed. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri., Mar. 1, 2019, 7:12 p.m. Brandt Bucher, <<a href="mailto:brandtbucher@gmail.com">brandtbucher@gmail.com</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"><div><font size="2">While working through my implementation, I've come across a couple of inconsistencies with the current proposal:</font><font size="2"><br></font></div><div><font size="2"><br></font></div><div><font size="2">> The merge operator will have the same relationship to the
<span class="m_1042493980587867862gmail-docutils m_1042493980587867862gmail-literal">dict.update</span> method as the list concatenation operator has to
<span class="m_1042493980587867862gmail-docutils m_1042493980587867862gmail-literal">list.extend</span>, with dict difference being defined analogously.</font></div><div><font size="2"><br></font></div><div><font size="2">I like this premise. += for lists *behaves* like extend, and += for dicts *behaves* like update.</font></div><div><font size="2"><br></font></div><div><font size="2">However, later in the PEP it says:<br></font></div><div><font size="2"><br></font></div><div><font size="2">> Augmented assignment will just call the <span class="m_1042493980587867862gmail-docutils m_1042493980587867862gmail-literal">update</span> method. This is
analogous to the way <span class="m_1042493980587867862gmail-docutils m_1042493980587867862gmail-literal">list +=</span> calls the <span class="m_1042493980587867862gmail-docutils m_1042493980587867862gmail-literal">extend</span> method, which
accepts any iterable, not just lists.</font></div><div><font size="2"><br></font></div><div><font size="2">In your Python implementation samples from the PEP, dict subclasses will behave differently from how list subclasses do. List subclasses, without overrides, return *list* objects for bare "+" operations (and "+=" won't call an overridden "extend" method). So a more analogous pseudo-implementation (if that's what we seek) would look like:</font></div><div><font size="2"><br></font></div><div><pre class="m_1042493980587867862gmail-literal-block"><span style="font-family:arial,helvetica,sans-serif"><font size="2">def __add__(self, other):<br>    if isinstance(other, dict):<br>        new = dict.copy(self)<br>        dict.update(new, other)<br>        return new<br>    return NotImplemented<br><br> def __radd__(self, other):
    if isinstance(other, dict):
        new = dict.copy(other)
        dict.update(other, self)
        return new
    return NotImplemented<br><br>def __iadd__(self, other):
    if isinstance(other, dict):
        dict.update(self, other)
        return self
    return NotImplemented<br><br></font></span></pre><pre class="m_1042493980587867862gmail-literal-block"><span style="font-family:arial,helvetica,sans-serif"><font size="2">This is what my C looks like right now. We can choose to update these semantics to be "nicer" to subclasses, but I don't see any precedent for it (lists, sets, strings, etc.).<br><br></font></span></pre><pre class="m_1042493980587867862gmail-literal-block"><span style="font-family:arial,helvetica,sans-serif"><font size="2">Brandt<br></font></span></pre></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 1, 2019 at 11:41 AM Brett Cannon <<a href="mailto:brett@python.org" target="_blank" rel="noreferrer">brett@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 1, 2019 at 8:50 AM Brandt Bucher <<a href="mailto:brandtbucher@gmail.com" target="_blank" rel="noreferrer">brandtbucher@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">I’ve never been part of this process before, but I’m interested in learning and helping any way I can.</div></blockquote><div><br></div><div>Thanks!<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><br></div><div>My addition implementation is attached to the bpo, and I’m working today on bringing it in line with the PEP in its current form (specifically, subtraction operations).</div><div><br></div><div><a href="https://github.com/python/cpython/pull/12088" target="_blank" rel="noreferrer">https://github.com/python/cpython/pull/12088</a></div></div></blockquote><div><br></div><div>When your proposed patch is complete, Brandt, just ask Steven to update the PEP to mention that there's a proposed implementation attached to the issue tracking the idea.</div><div><br></div><div>-Brett<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><br><br><div id="m_1042493980587867862gmail-m_-1415228650723199591gmail-m_6726235704665142903AppleMailSignature" dir="ltr">Brandt</div><div dir="ltr"><br>On Mar 1, 2019, at 08:26, Steven D'Aprano <<a href="mailto:steve@pearwood.info" target="_blank" rel="noreferrer">steve@pearwood.info</a>> wrote:<br><br></div><blockquote type="cite"><div dir="ltr"><span>Attached is a draft PEP on adding + and - operators to dict for </span><br><span>discussion.</span><br><span></span><br><span>This should probably go here:</span><br><span></span><br><span><a href="https://github.com/python/peps" target="_blank" rel="noreferrer">https://github.com/python/peps</a></span><br><span></span><br><span>but due to technical difficulties at my end, I'm very limited in what I </span><br><span>can do on Github (at least for now). If there's anyone who would like to </span><br><span>co-author and/or help with the process, that will be appreciated.</span><br><span></span><br><span></span><br><span>-- </span><br><span>Steven</span><br></div></blockquote><blockquote type="cite"><div dir="ltr"><dict_addition_pep.txt></div></blockquote><blockquote type="cite"><div dir="ltr"><span>_______________________________________________</span><br><span>Python-ideas mailing list</span><br><span><a href="mailto:Python-ideas@python.org" target="_blank" rel="noreferrer">Python-ideas@python.org</a></span><br><span><a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank" rel="noreferrer">https://mail.python.org/mailman/listinfo/python-ideas</a></span><br><span>Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank" rel="noreferrer">http://python.org/psf/codeofconduct/</a></span><br></div></blockquote></div></div>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank" rel="noreferrer">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="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" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div></div>
</blockquote></div>

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.<br>
To unsubscribe from this topic, visit <a href="https://groups.google.com/d/topic/python-ideas/jq5QVTt3CAI/unsubscribe" target="_blank" rel="noreferrer">https://groups.google.com/d/topic/python-ideas/jq5QVTt3CAI/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href="mailto:python-ideas+unsubscribe@googlegroups.com" target="_blank" rel="noreferrer">python-ideas+unsubscribe@googlegroups.com</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="noreferrer">https://groups.google.com/d/optout</a>.<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank" rel="noreferrer">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="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" target="_blank">http://python.org/psf/codeofconduct/</a><br>
<br>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.<br>
To unsubscribe from this topic, visit <a href="https://groups.google.com/d/topic/python-ideas/jq5QVTt3CAI/unsubscribe" rel="noreferrer noreferrer" target="_blank">https://groups.google.com/d/topic/python-ideas/jq5QVTt3CAI/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href="mailto:python-ideas%2Bunsubscribe@googlegroups.com" target="_blank" rel="noreferrer">python-ideas+unsubscribe@googlegroups.com</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout" rel="noreferrer noreferrer" target="_blank">https://groups.google.com/d/optout</a>.<br>
</blockquote></div>