<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> 

<span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span> </span>I'd want to see code that currently uses ``if isinstance`` to switch between ``max(x)`` and ``x.max()``.<span> </span></span>

</blockquote><div><br></div><div>I understand that, and I've spent a few hours searching github with less-than-stellar results due to github's <a href="https://help.github.com/articles/searching-code/#considerations-for-code-search">search syntax ignoring '.' and '('</a>.  (That being said, <a href="https://github.com/search?l=Python&q=__min__&type=Code">there are a number of projects</a> on github that seem to expect __min__ to work (<a href="https://github.com/windowssocket/algorithm/blob/d731dca2917b6d6073a49d53cf4376b75da7e0c7/binarysearchtree.py">example</a>), but it's true that some are using the dunder for their own purposes.).</div><div><br></div><div>However, there are many modules that implement objects that could make good use of exposing __min__ (e.g. <a href="https://pypi.org/project/bintrees/">bintrees</a>, <a href="http://www.grantjenks.com/docs/sortedcontainers/">sortedcontainers</a>).  </div><div><br></div><div>bintrees provides `min_item()` and `max_item()` accessors.  sortedcontainers doesn't seem to explicitly provide similar methods, but maintain the sortedness of the objects so min and max can be accessed via index.</div><div><br></div><div>And I can't stress enough the value in being able to switch to one of these classes from a standard iterable and have the rest of your code (e.g. `min()`s "just work").</div><div><br></div><div>Also, the <a href="https://stackoverflow.com/questions/45308212/is-there-a-way-to-return-a-custom-value-for-min-and-max-in-python">desire for custom implementations is there</a>, but the proposed solutions rely on (IMO) ugly hacks that would break other things.</div><div><br></div><div>The search for the perfect `x.min() if isinstance(...) else min(x)` still continues, however.</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 27, 2018 at 11:30 AM, Michael Selik <span dir="ltr"><<a href="mailto:mike@selik.org" target="_blank">mike@selik.org</a>></span> wrote:<br><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"><span class=""><div dir="ltr">On Wed, Jun 27, 2018 at 8:16 AM Franklin? Lee <<a href="mailto:leewangzhong%2Bpython@gmail.com" target="_blank">leewangzhong+python@gmail.com</a><wbr>> wrote:<br></div></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><div class="gmail_quote"><span class=""><div dir="ltr">On Wed, Jun 27, 2018, 10:31 Steven D'Aprano <<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>> wrote:<br></div></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Wed, Jun 27, 2018 at 06:52:14AM -0700, Michael Selik wrote:<br></span><span class="">
> My intent was to ask where a range was in fact passed into max, not merely<br>
> where it could be. It'd be enlightening to see a complete, realistic<br>
> example.<br>
<br>
A complete, realistic example is as I said: you call max() on some <br>
object which you don't control, the caller does. You could be <br>
passed a list, or a set, or a bitset, a binary search tree, a range <br>
object, whatever the caller happens to pass to you.<br></span></blockquote></div></div><div dir="auto"><br></div></div><span class=""><div dir="auto"><div dir="auto">Let's just assume Michael wants to know, and isn't making an argument against the proposal.</div></div></span></blockquote><div><br></div><div>I do want to know, but it's also an argument against the proposal -- that no one has contributed in-context usage to demonstrate the value. I'd want to see code that currently uses ``if isinstance`` to switch between ``max(x)`` and ``x.max()``. Chris Barker explained the issue well.</div></div></div>
<br>______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
<br></blockquote></div><br></div>