iterators and views of lists

Brendan Miller catphive at catphive.net
Sat Dec 19 00:51:46 EST 2009


On Fri, Dec 18, 2009 at 2:47 PM, Bearophile <bearophileHUGS at lycos.com> wrote:
> Brendan Miller:
>> I agree though, it doesn't matter to everyone and anyone. The reason I
>> was interested was because i was trying to solve some specific
>> problems in an elegant way. I was thinking it would be cool to make
>> python more usable in programming competitions by giving it its own
>> port of the STL's algorithm library, which needs something along the
>> lines of C++'s more powerful iterators.
>
> It seems you have missed my post, so here it is, more explicitly:
>
> http://www.boostcon.com/site-media/var/sphene/sphwiki/attachment/2009/05/08/iterators-must-go.pdf
>
> Bye,
> bearophie
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Andrei is arguing for replacing iterators with ranges, which are
equivalently powerful to C++ iterators but easier to use. Actually,
what I want in python is something like this.

If you look at Anh Hai Trinh's posts he implemented something
basically like a python version of andre's ranges, which he called
listagents. That pdf is interesting though because he's thought
through what an interface for bidrectional ranges should look like
which I had not yet.

However, you should note that andrei's ranges allow mutation of the
original datastructure they are a range over. My impression from your
earlier post was that you disagreed with that idea of mutating
algorithms and wanted something more functional, whereas I, and andrei
in that pdf, are more concerned with imperative programming and in
place algorithms.

I don't want to get into a big discussion about FP vs imperative
programming, as that is simply too large a topic and I have had that
discussion many times before. I'm more of a turing machine than a
lambda calculus guy myself, but if other people make other choices
that's fine with me.



More information about the Python-list mailing list