[Python-Dev] Re: Documenting sorted/min/max prerequisites

2019-12-15 Thread Serhiy Storchaka
15.12.19 12:27, Steven D'Aprano пише: Since list.sort guarantees that it will only use the `<` less than operator, should we make the same guarantee for sorted, min and/or max? Perhaps. And also for heapq and maybe some other functions. Do you mind to create a PR? It is common to make generi

[Python-Dev] Re: Documenting sorted/min/max prerequisites

2019-12-15 Thread Steven D'Aprano
On Sat, Dec 14, 2019 at 04:20:43PM +0200, Serhiy Storchaka wrote: > 14.12.19 15:29, Steven D'Aprano пише: > >I might be misinterpreting the evidence, but sorting works on objects > >that define `__gt__` without `__lt__`. [...] > The `<` operator try to use `__lt__`, but if it is not defined falls

[Python-Dev] Re: Documenting sorted/min/max prerequisites

2019-12-14 Thread Christian Heimes
On 14/12/2019 15.20, Serhiy Storchaka wrote: > 14.12.19 15:29, Steven D'Aprano пише: >> I might be misinterpreting the evidence, but sorting works on objects >> that define `__gt__` without `__lt__`. >> >> py> class A: >> ... def __init__(self, x): self.x = x >> ... def __gt__(self, other):

[Python-Dev] Re: Documenting sorted/min/max prerequisites

2019-12-14 Thread Serhiy Storchaka
14.12.19 15:29, Steven D'Aprano пише: I might be misinterpreting the evidence, but sorting works on objects that define `__gt__` without `__lt__`. py> class A: ... def __init__(self, x): self.x = x ... def __gt__(self, other): return self.x > other.x ... py> L = [A(9), A(1), A(8)] py> L.

[Python-Dev] Re: Documenting sorted/min/max prerequisites

2019-12-14 Thread Steven D'Aprano
On Sat, Dec 14, 2019 at 02:40:04PM +0200, Serhiy Storchaka wrote: > 14.12.19 12:45, Steven D'Aprano пише: > >The list.sort method is documented to only use less than: > > > >https://docs.python.org/3/library/stdtypes.html#list.sort > > > >but I don't think that is correct, it seems to use greater t

[Python-Dev] Re: Documenting sorted/min/max prerequisites

2019-12-14 Thread Serhiy Storchaka
14.12.19 12:45, Steven D'Aprano пише: The list.sort method is documented to only use less than: https://docs.python.org/3/library/stdtypes.html#list.sort but I don't think that is correct, it seems to use greater than if it exists and less than doesn't. My understanding is that items need to de