[Python-Dev] PySequence_Check but no __len__
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Jun 22 20:08:24 EDT 2018
Ivan Pozdeev via Python-Dev wrote:
> the documentation seems to use "sequence" in the sense
> "finite iterable". Functions that need to know the length of input in
> advance seem to be the minority.
The official classifications we have are:
Sequence: __iter__, __getitem__, __len__
Iterable: __iter__
There isn't any official term for a sequential thing that
has __iter__ and __getitem__ but not __len__.
That's probably because the need for such a thing doesn't
seem to come up very much. One usually processes a
potentially infinite sequence by iterating over it, not
picking things out at arbitrary positions. And usually
its items are generated by an algorithm that works
sequentially, so random access would be difficult to
implement.
--
Greg
More information about the Python-Dev
mailing list