Raymond Hettinger schrieb: >> 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. > > Do you expect that next(someiterator) will be just > as fast and calling a boundmethod (such as: > counter=itertools.counter(1); counter())?
I would think so, yes. counter will be a method-wrapper, calling it will create an empty argument tuple (or rather pass the singleton one), this will call wrap_next, which will call count_next. A builtin (or otherwise global) next() function will be METH_O, so no argument tuple is created, and tp_iternext is invoked directly. As no memory allocation should happen in either case, and all checks are pretty fast, the difference should be minor, though. Regards, Martin _______________________________________________ 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