Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10617

Re: What is xrange?

Date 2011-07-30 23:42 -0700
From Ethan Furman <ethan@stoneleaf.us>
Subject Re: What is xrange?
References <j0v23e$g6o$1@speranza.aioe.org> <4e335ce4$0$29977$c3e8da3$5496439d@news.astraweb.com> <mailman.1654.1312025049.1164.python-list@python.org> <4e33ecc4$0$29987$c3e8da3$5496439d@news.astraweb.com> <j126a1$v8o$1@dough.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.1688.1312094634.1164.python-list@python.org> (permalink)

Show all headers | View raw


Dennis Lee Bieber wrote:
> On Sat, 30 Jul 2011 21:36:41 +1000, Steven D'Aprano
> <steve+comp.lang.python@pearwood.info> declaimed the following in
> gmane.comp.python.general:
> 
> 
>> Probably because nobody thought about it, but if it had been proposed to
>> change xrange into an iterator, I'm pretty confident that the suggestion
>> would have been rejected. 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, but what did they change range() into -- I seem to recall
> reading the Python 3.x turned the regular range() into something else...
> (from Python <3.x returning a full list)

 From the What's New docs, in the Views And Iterators Instead Of Lists 
section:

range() now behaves like xrange() used to behave, except it works with 
values of arbitrary size. The latter no longer exists.

~Ethan~

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

What is xrange? Billy Mays <noway@nohow.com> - 2011-07-29 15:36 -0400
  Re: What is xrange? harrismh777 <harmar@member.fsf.org> - 2011-07-29 14:47 -0500
  Re: What is xrange? Thomas Jollans <t@jollybox.de> - 2011-07-29 22:31 +0200
  Re: What is xrange? Jerry Hill <malaclypse2@gmail.com> - 2011-07-29 16:36 -0400
  Re: What is xrange? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-30 11:22 +1000
    Re: What is xrange? Brian Blais <bblais@bryant.edu> - 2011-07-30 06:23 -0400
      Re: What is xrange? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-30 21:36 +1000
        Re: What is xrange? Brian Blais <bblais@bryant.edu> - 2011-07-30 09:46 -0400
        Re: What is xrange? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-07-30 17:06 -0700
        Re: What is xrange? Chris Angelico <rosuav@gmail.com> - 2011-07-31 01:10 +0100
        Re: What is xrange? Ethan Furman <ethan@stoneleaf.us> - 2011-07-30 23:42 -0700
      Re: What is xrange? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-07-31 12:18 +1200

csiph-web