[Python-3000] rename it.next() to it.__next__(), add a next() built-in
"Martin v. Löwis"
martin at v.loewis.de
Tue Mar 6 12:28:38 CET 2007
Terry Reedy schrieb:
> On the consistency argument: sorted(somelist) calls copy(somelist).sort,
> not copy(somelist).__sort__.
Actually, it calls list(somelist).sort, so it requires iteration, not
copying, and the result will be known to be a list. So the important
difference is that .sort is not a method that the argument to sorted
needs to implement (indeed, it has no option to define its own sorting
algorithm). This is different from __next__, which user-defined types
will need to implement.
> One of the virtues, and as I recall, design purposes, of .next calls is to
> be fast.
I think this holds for the C level only. Python-level invocations will
create a method-wrapper (or bound method) every time, so that won't
More information about the Python-3000