range or xrange disallowed for big numbers

Terry Reedy tjreedy at udel.edu
Mon Oct 7 23:09:54 EDT 2002


"Chad Netzer" <cnetzer at mail.arc.nasa.gov> wrote in message
news:mailman.1034021771.11695.python-list at python.org...
> On Saturday 05 October 2002 03:23, Alex Martelli wrote:
> > Chad Netzer wrote:
> > > Is there a reason (technical or philosophical) to disallow:
> > >
> > >     range( 10000000000L, 10000000000L + 1L )
> >
> > Slowing down common cases of range and xrange (by keeping
PyObject's
> > or Python longs rather than C-level long's) is an unpleasant
prospect,

Why should it slow down?  If all args are ints (and they are now
tested for intness), proceed as currently.  No slowdown.  At the point
where exception is now raised, see if have PyLong instead, and take
alternate path if feasible.  This only slows down raising of exception
if cannot proceed.  For xrange, alternate is to return longxrange
object (or iterator) instead of usual xrange object.  This does expand
code size by size of alternate path and slightly increases maintenance
burden.

Have I missed something?

Terry J.Reedy





More information about the Python-list mailing list