On Wed, Mar 4, 2020 at 10:22 AM Richard Damon <Richard@damon-family.org> wrote:
> But on one narrow point, I'm trying to think of everything in the standard library or builtins that actually forms a total order with elements of the same type.
> * Not floats
> * I think not strings with unicode canonical equivalence, decomposition, and normalization
> * Definitely not sets, tuples, lists, dicts, etc.
> * Arguably not Decimal because it is sensitive to decimal context
> * Complex clearly not
> * I think not datetimes under timezone issues (although any ordering is certainly *wrong* given the vagaries of timezones)
> * Queues, deques, etc. don't even try, nor should they
> * Do array.array's lack even a partial order?
> So really I think we are left with wanting a test for whether something is "int or Fraction".

I think strings do have the Total Order property, because string equality & etc does NOT get into the issues of Unicode canonical equivalence, I.e. the equality test is that they are the same sequence of code points, ignoring that multiple sequences of code points might be represent the same same canonical character, in part because there isn’t a single definition of that, as there is NFD/NFC and NFKD/NFKC equivalences which are different.

Fair enough. I'm kinda conflating (kinda deliberately) the Python level of "what does the less-than operator do" with "what is meaningfully less that what for the actual problem?"

And I'm also fudging the Decimal question too.  The relationship between *expressions* can vary by decimal context.  But not of a value named by a single variable. However, the expression can be quite simple:

>>> with decimal.localcontext() as ctx:
...     ctx.prec = 2
...     print(+a < b)
>>> with decimal.localcontext() as ctx:
...     ctx.prec = 10

...     print(+a < b)

Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.