[Types-sig] Another cut at Sequence declarations
Marcin 'Qrczak' Kowalczyk
qrczak@knm.org.pl
17 Mar 2001 13:49:13 GMT
Wed, 14 Mar 2001 16:10:56 -0700, Tim Hochberg <tim.hochberg@ieee.org> pis=
ze:
> I defined three protocols: Iterable, BasicSequence and Sequence.
> Iterable is something you can iterate on. Currently that means it
> supports getitem, but this will be expanded to include whatever
> the iter-sig comes up with. BasicSequence supports getitem and
> len. This is the minimum that you need to construct an immutable
> sequence (e.g., a tuple).
What about lazily computed or infinite sequences, when you should
not request the length in advance, or even ever?
Fortunately iterators discussed on iter-sig don't work in terms of
indexing and length, so they are compatible with lazy lists (e.g.
reading lines from a file).
> Finally, there is a class SequenceWrapper that creates a Sequence out o=
f
> a BasicSequence. It's used as "aSequence=3DSequenceWrapper(aBasicSequen=
ce)"
> I'm not sure how necessary this is since "tuple(aBasicSequence)" would
> work as well or better in most situations.
It won't work for lazy lists.
--=20
__("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZAST=CAPCZA
QRCZAK