A Standard

Andrew Koenig ark at research.att.com
Mon May 26 13:54:56 EDT 2003


>> What I see in this description is that the Python notion of "sequence
>> types" is decidedly non-sequential, because __getitem__ really takes an
>> arbitrary index as input.  So what Python calls a "sequence type" is
>> closest to the C++ notion of a random-access iterator, except that you
>> cannot offset such an iterator by an integer to obtain a new iterator.

>> Such differences can have surprisingly profound effects on programs.


Jay> I thought a Python 'sequence type' was closer to a C notation of an array?
Jay>   You can iterate sequentially over a sequence type, but a sequence type,
Jay> but that's really a linear wrapper using a random access mechanism

Right.  That's what I meant when I said that Python sequence types are
non-sequential.  As far as I can see, Python has no notion to correspond
to the C++ notion of a forward iterator.

Of course, whether it should have such a notion is another matter entirely.
I still think it's an interesting research question.

-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark




More information about the Python-list mailing list