Python is faster than C
Raymond Hettinger
python at rcn.com
Mon Apr 5 02:41:30 EDT 2004
[Armin Rigo]
> Armin> Worse, and more importantly, the optimization starts to
> Armin> become visible to the programmer. Iterators, for example,
> Armin> are great in limited cases but I consider their
> Armin> introduction a significant complication in the language;
> Armin> before, you could expect that some function from which you
> Armin> would expect a sequence returned a list. Python was all
> Armin> lists and
[Ville Vainio]
> Iterators are an optimization? I always considered them just a more
> clean and elegant way to do the same thing :-).
In the planning discussions, optimization was not mentioned as goal.
In fact, I think everyone was surprised that they happened to run
faster than the __getitem__ hack. It was also a surprise at how much
they unified the language and made the various pieces work together a
little better.
The original goals were much smaller:
* less cumbersome file iteration (eliminating the need for xreadlines
and reducing the need for the fileinput module).
* providing an extensible interface
* making the code for non-sequence collections more concise and
readable
There was a thought that the performance of dictionary iteration would
improve. Also, while it was not discussed explicitly, everyone was
aware that iterators were more memory/cache friendly than their list
based counterparts.
Raymond Hettinger
More information about the Python-list
mailing list