[Python-Dev] iterator API in Py3.0 (original) (raw)

Aahz aahz at pythoncraft.com
Fri Mar 3 20:15:12 CET 2006


On Wed, Mar 01, 2006, Raymond Hettinger wrote:

I usually let this sort of thing slide, but the iterator API is too important for trivial, incompatible, and damaging changes. Looking back at Guido's original rationale for naming the method next() instead of next(), http://www.python.org/peps/pep-0234.html , it does not look like any of those reasons will cease to apply in Py3.0.

OTOH, there is a final comment that choosing next() was perhaps a mistake that cannot be rectified. However, it can certainly be fixed in Python 3.0.

My argument in favor of switching to next() is rather simple:

As for your point about efficiency, I don't much care whether we get a built-in next() function, but I think that anyone who is concerned about efficiency should do

next = obj.__next__

which saves an attribute lookup, too. I still think the vast majority of cases will stick with for loops that automatically call next() directly.

Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/

"19. A language that doesn't affect the way you think about programming, is not worth knowing." --Alan Perlis



More information about the Python-Dev mailing list