Recap: PEP 276 Simple Iterator for ints
William Tanksley
wtanksle at dolphin.openprojects.net
Fri Nov 16 18:59:09 EST 2001
On Fri, 16 Nov 2001 14:46:51 -0800, James_Althoff at i2.com wrote:
>It seems to me that, given the need (or desire) for both a list constructor
>and an iterator, you either provide both -- and add extra
>ugliness/complexity to your syntax and/or calling conventions in the
>process (the "x" in "xrange", for example) -- or you provide the iterator
>in convenient form and the list constructor in less convenient form (as you
>propose by using the list function on the return of an iterator from a
>slice on integers). Or you don't provide the iterator at all and don't
>worry about big lists. My comment was put in to encourage folks to take
>this tradeoff into account when detailing similar proposals.
It isn't even a tradeoff.
You can provide both __getitem__ and __iter__, and you're set. Providing
__getitem__ doesn't mean you're a list or tuple; it just means you're a
sequence. If you do that the way range() has in the past, you're an
idiot. There's absolutely no reason to store all the integers in a range
which you could instead store start,stop,and step, and generate them as
needed.
>Jim
--
-William "Billy" Tanksley
More information about the Python-list
mailing list