[issue2690] Precompute range length

Alexander Belopolsky report at bugs.python.org
Fri Apr 25 21:24:02 CEST 2008


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

Option (3) would require changing both sq_item and sq_length signatures,
which is likely to have a large negative impact on performance.

Option (2) would either require a change for the sq_length signature, or
leave the problem of having valid range objects for which applying len()
would produce an OverflowError.

What are the use cases for ranges with length greater than maxsize? Note
that in 2.x all arguments to length are limited to 32 bit integers (even
on 64-bit platforms) and the main reason to support long start/stop/step
in 3.0  is because 2.x range() supports them.  On the other hand, since
2.x range() produces lists, it is limited in length to a fraction of
sys.maxsize.  Therefore none of the current uses of either range or
xrange require support of long length.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2690>
__________________________________


More information about the Python-bugs-list mailing list