What is xrange?

Brian Blais bblais at bryant.edu
Sat Jul 30 15:46:01 CEST 2011


On Jul 30, 2011, at 7:36 AM, Steven D'Aprano wrote:

> xrange objects might be lazily generated, but
> they're also sequence types: you can get their length, and you can index
> them. (However you can't slice them.) Iterators are not sequence types:
> they aren't indexable and you can't get their length.

ah!  now that makes sense.  I guess I never check their length, or index them, and only use them like generators.  :)

thanks for the clarification!

> It isn't like the Python developers are sitting around bored, looking for
> things to do. They are overworked with far too much to do and not enough
> manpower or time to do it. There are a huge number of much more important
> bug fixes and features that haven't been dealt with for them to bother with
> something like this.

Now, that seems a little harsh, and nothing that I was intending.  I figured (before learning about getting its length and indexing) that if the xrange object was basically a pre-generator hack, that it would make sense from a code-clarity point of view to reimplement them as generators -- it would gave made the developer's life easier.  Now that I realize that xrange has different functionality than a generator (which was the point of my question...just curious *what* different functionality) it clearly doesn't make sense to implement them as generators.  I certainly wasn't trying to imply that the developers are lazy, or bored!


			bb
> 
> 
> 
> -- 
> Steven
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list

-- 
Brian Blais
bblais at bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/






More information about the Python-list mailing list