>
> Is there any commonly used or even imaginable useful type that uses them
> in weirder ways than set and float (which are both partially ordered) or
> np.array (where they aren’t even Boolean-values)? In particular,
> transitivity keeps coming up, but all of those examples are transitive
> (it’s never true that a<b and true that b<c without being true than a<c for
> any of them). If there are such uses it might be important to distinguish
> them, but if there aren’t, it doesn’t seem unreasonable for
> PartiallyOrdered to “wrongly” pick up hypothetical pathological types that
> no one will ever write in exchange for automatically being right about
> every actual type anyone uses. After all, Iterable is a virtual superclass
> of any type with __iter__, even if it returns the number 42 instead of an
> Iterator, and so on; technically every implicit ABC in Python is “wrong”
> like this, but in practice it doesn’t come up and implicit ABCs are very
> useful.
>

I think that np.array is a great example of something I wouldn't want to be
PartiallyOrdered. An algorithm which requires PartiallyOrdered probably
needs to use the results of comparisons as booleans and for np.array that
will fail immediately. Same thing for pandas Series and DataFrames. Another
example which comes to mind is SQLAlchemy columns which produce part of a
query for the ORM - these presumably can be used as booleans but not in an
informative way.

There are 3 possible ABCs: Comparable (has the operators, makes no promises
about what they do), PartiallyOrdered, and TotallyOrdered. We could have
all three. If we don't want that but we want to distinguish between
TotallyOrdered and others, we need one of the other two. Which option is
more useful? It's probably rare that someone specifically needs
PartiallyOrdered and not the other two. But Comparable is just a protocol
that anyone can implement.

I should note that I've never personally needed any of this, I'm just
trying to imagine use cases. But I think a 'negative' ABC as I believe was
originally proposed is the wrong path.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/UFV6TYKZWQZURY3JCMZ3J5TPWRRELFNU/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to