iterators and views of lists

Terry Reedy tjreedy at udel.edu
Wed Dec 16 00:09:34 EST 2009


On 12/15/2009 10:39 PM, Brendan Miller wrote:
> I was trying to reimplement some of the c++ library of generic
> algorithms in c++ in python, but I was finding that this is
> problematic to do this in a generic way because there isn't any
> equivalent of c++'s forward iterators, random access iterators, etc.
> i.e. all python iterators are just input iterators that can't mutate
> the sequence they iterate over nor move backwards or by an arbitrary
> offset.
>
> I'm wondering if anyone has done work towards creating more powerful
> iterators for python, or creating some more pythonic equivalent.

For sequences, integer indexes let you do anything you want that the 
container supports. No need for anything more, though you can wrap ints 
if you must. The read-only iterator protocal is intentionally minimal. I




More information about the Python-list mailing list