On Fri, Jul 3, 2020, at 03:57, Wes Turner wrote:
> Can a Sequence be infinite? If so, an equality test of two
> nonterminating sequences would be a nonterminating operation.
I think not - an infinite sequence would make len, contains, and reversed ill-defined (it also wouldn't allow certain kinds of slices)
> Do Sized and *Reversible* imply that a sequence terminates?
> Could __len__ return inf?
__len__ must return an integer.
> Perhaps `Ordered` is a requisite condition for defining a comparator
> for Sequences.
> `OrderedSequence`?
>
> Are there unordered Sequences for which a default `__eq__` / `__cmp__`
> (et. al) would be wrong or inappropriate?
I don't think so [index as a mixin implies being ordered, i think]... the bigger problem is the one I mentioned earlier, that allowing comparison between sequences of different types is inconsistent with tuple and list.
As far as types are concerned, the `__eq__` should worry about it - just Sequences that are
a subtype of other, or the other being a subtype of one, should be able to compare equal
(As happens with lists and tuples as well: subclasses of both will compare equal to base lists and tuples
with the same content.).
The code for that is on my first reply to Guido, above:
if not issubclass(type(other), type(self)) and not issubclass(type(self), type(other)):
return False
I am actually using that on the file that motivated me sending the first e-mail here -as it
makes sense in that project.