Terry Reedy wrote: > One of the virtues, and as I recall, design purposes, of .next calls is to > be fast. After the first call, execution jumps directly into the > pre-existing stack frame.
You're thinking of generators, but not all iterators are implemented by generators. The built-in ones are implemented in C. Invoking a builtin .next() method via a protocol function shouldn't be any slower than it is now. In both cases you've got one name lookup and one Python call, after which you go through the type slot directly to a C function. > It is then fairly > standard to factor out the attribute lookup with with 'xnext = x.next' You could still do xnext = x.__next__ if you wanted. -- Greg _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com