[Python-3000] rename it.next() to it.next(), add a next() built-in (original) (raw)

"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 be fast.

Regards, Martin



More information about the Python-3000 mailing list