AndyL  <[EMAIL PROTECTED]> wrote:
>Paul Rubin wrote:
>> Normally you'd use range or xrange.  range builds a complete list in
>> memory so can be expensive if the number is large.  xrange just counts
>> up to that number.
>so when range would be used instead of xrange. if xrange is more 
>efficient, why range was not reimplemented?

If you actually want the list for some reason:

$ python2.4 -mtimeit 'list(xrange(100))'
100000 loops, best of 3: 4.54 usec per loop
$ python2.4 -mtimeit 'range(100)'
100000 loops, best of 3: 2.61 usec per loop

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to