<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">Good catch,</p>
<p style="margin:0px 0px 1.2em!important">I think the latter failing is because <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">np.add.reduce</code> ends up calling <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">np.ufunc.reduce.__get__(np.add)</code>, and <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">builtin_function.__get__</code> doesn’t appear to do any caching. I suppose caching bound methods would just be a waste of time.<br><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">==</code> would work just fine in my suggestion above, it seems - irrespective of the resolution of the discussion on python-dev.</p>
<p style="margin:0px 0px 1.2em!important">Eric</p>
<div title="MDH:R29vZCBjYXRjaCw8ZGl2Pjxicj48L2Rpdj48ZGl2PkkgdGhpbmsgdGhlIGxhdHRlciBmYWlsaW5n
IGlzIGJlY2F1c2UgYG5wLmFkZC5yZWR1Y2VgIGVuZHMgdXAgY2FsbGluZyBgbnAudWZ1bmMucmVk
dWNlLl9fZ2V0X18obnAuYWRkKWAsIGFuZCBgYnVpbHRpbl9mdW5jdGlvbi5fX2dldF9fYCBkb2Vz
bid0IGFwcGVhciB0byBkbyBhbnkgY2FjaGluZy4gSSBzdXBwb3NlIGNhY2hpbmcgYm91bmQgbWV0
aG9kcyB3b3VsZCBqdXN0IGJlIGEgd2FzdGUgb2YgdGltZS48ZGl2Pjxicj48L2Rpdj48ZGl2PmA9
PWAgd291bGQgd29yayBqdXN0IGZpbmUgaW4gbXkgc3VnZ2VzdGlvbiBhYm92ZSwgaXQgc2VlbXMg
LSBpcnJlc3BlY3RpdmUgb2YgdGhlIHJlc29sdXRpb24gb2YgdGhlIGRpc2N1c3Npb24gb24gcHl0
aG9uLWRldi48YnI+PGRpdj48YnI+PC9kaXY+PGRpdj5FcmljPC9kaXY+PC9kaXY+PC9kaXY+" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0">​</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, 29 Jun 2018 at 18:24 Stephan Hoyer <<a href="mailto:shoyer@gmail.com">shoyer@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 class="gmail_quote"><div dir="ltr">On Thu, Jun 28, 2018 at 5:36 PM Eric Wieser <<a href="mailto:wieser.eric%2Bnumpy@gmail.com" target="_blank">wieser.eric+numpy@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 class="m_2664422732684312692m_-7140197388356590847markdown-here-wrapper"><p style="margin:0px 0px 1.2em!important">Another option would be to directly compare the methods against known ones:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important">obj = func.__self__
if isinstance(<span style="font-size:11.05px">obj</span>, np.ufunc):
    if func is obj.reduce:
        got_reduction()</code></pre></div></div></blockquote></div></div><div dir="ltr"><div class="gmail_quote"><div>I'm not quite sure why, but this doesn't seem to work with current ufunc objects:</div><div><br></div><div><div>>>> np.add.reduce == np.add.reduce  # OK</div><div>True </div><br class="m_2664422732684312692inbox-inbox-Apple-interchange-newline"></div><div>>>> np.add.reduce is np.add.reduce  # what?!?<br></div><div>False</div><div><br></div><div>Maybe this is a bug? There's been some somewhat related discussion recently on python-dev:</div><div><a href="https://mail.python.org/pipermail/python-dev/2018-June/153959.html" target="_blank">https://mail.python.org/pipermail/python-dev/2018-June/153959.html</a><br></div><div><br></div><div><br></div></div></div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div>