Nick Coghlan <[EMAIL PROTECTED]> added the comment:

Given that range() produced a list in the 2.x series (hence limited to
available memory), and xrange() uses int internally for its values (and
hence couldn't even cope with short ranges with values greater than
sys.maxint).

So my preference is to mimic the 2.x range's behaviour in this case by
raising an overflow error if the sequence is too long.

(From Python 2.5.1)

>>> range(2**99, 2**100)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: range() result has too many items
>>> range(2**99, 2**99+5)
[633825300114114700748351602688L, 633825300114114700748351602689L,
633825300114114700748351602690L, 633825300114114700748351602691L,
633825300114114700748351602692L]
>>> xrange(2**99, 2**99+5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: long int too large to convert to int

----------
nosy: +ncoghlan

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2690>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to