On Fri, 18 Dec 2009 21:10:28 -0000, Brendan Miller <catph...@catphive.net> wrote:

When I said they are "weak" I meant it in sense that the algorithms
writeable against an InputerIterator interface (which is what python's
iterator protocol provides) is a proper subset of the algorithms that
can be written against a RandomAccessIterator interface. The class of
algorithms expressible against a python iterator is indeed limited to
those that can be expressed with a for each loop or map/reduce
operation.

I think the most relevant thing that can be said to this is that you need to stop trying to write Python code as if it was C++. The languages constructs are intended for different purposes; iterators in C++ are part of the small arsenal of devices needed to provide type-independence to algorithms, something that comes a lot more easily to Python through dynamic typing and easy slicing. I'm barely literate in C++, but I can't see uses for a C++ random access iterator that aren't served in Python by simple indexing (possibly with additional bounds checking) or a Python iterator (possibly over a sliced sequence).

The downside, of course, is that you don't have the security provided by static type checking. You pays your money, you takes your choice; preferably, however, you don't do like a friend of mine and try to write FORTRAN in whatever language you're using!

--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to