A Standard

Andrew Koenig ark at research.att.com
Mon May 26 13:53:29 EDT 2003


Erik> Sure, but that doesn't mean that Python doesn't have the concept of an
Erik> abstract interface simply because its model for collections (sequence
Erik> types, mapping types) is different than STL's.

Agreed.  I've never said otherwise.  What I did say was that my current
impression is that Python has not been as systematic about defining such
concepts as C++ has been.

Erik> It's not surprising that Python's approach to sequence types is more
Erik> dynamic and less restrictive than C++'s STL approach, since Python is
Erik> more dynamic and less restrictive than C++.

I'm not sure I understand what this statement means.

For example, in C++, every random-access iterator is also a forward iterator.
Accordingly, every algorithm that operators on forward iterators will also
operate on random-access iterators.

In Python, the concepts of "iterator" and "sequence" are quite different
from one another, and I don't think there is any guarantee that every
program that works on iterators will also work on sequences.

How do these facts relate to your statement about "more dynamic and
less restrictive?"  I don't see it.  What I do see is that what I've
been calling the "abstraction layer" -- the notions of the iterator
categories in C++ and iterators and sequences in Python -- differ quite
substantially between the two languages, and that some, but not all,
of the differences stem from essential differences between the languages.

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




More information about the Python-list mailing list