[Raymond Hettinger] > Xrange was given its own tp_iter slot and now runs as fast a range. > In single pass timings, it runs faster. In multiple passes, range > is still quicker because it only has to create the PyNumbers once. > > Being immutable, xrange had the advantage that it could serve as its > own iterator and did not require the extra code needed for list > iterators and dict iterators. Did you write the pach that Martin checked in? It's broken. >>> a = iter(xrange(10)) >>> for i in a: print i if i == 4: print '*', a.next() 0 1 2 3 4 * 0 5 6 7 8 9 >>> Compare to: >>> a = iter(range(10)) >>> for i in a: print i if i == 4: print '*', a.next() 0 1 2 3 4 * 5 6 7 8 9 >>> --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4