iterators and views of lists

Carl Banks pavlovevidence at gmail.com
Wed Dec 16 09:06:08 EST 2009


On Dec 15, 11:48 pm, Brendan Miller <catph... at catphive.net> wrote:
> I was thinking you'd want something like random access iterators in
> c++, or pointers in c, to write typical in place algorithmic code. To
> me, something like non-copying slices (maybe you'd call it a list
> view?) would seem functionally similar and maybe more pythonic.


My general answer to the question, "Has anyone done any work in Python
to get a certain feature that we have in C++?, is, "There's little
demand for many features of C++ because they are actually workarounds
for the language's poor expressibility".  I'd say that's kind of the
case here.

C++ is poorly expressive (container operations are often an excercise
in line-noise-management), and values fine-tuned optimization.  So it
makes sense to offer things like mutator views that reduce the number
of container operations needed, and avoids copying.

Python expresses container operations succinctly and clearly, and
doesn't value performance as much.  Copying and replacing is good
enough most of the time, so there's less demand for things like
mutator views.


Carl Banks



More information about the Python-list mailing list