Message54218
Logged In: YES
user_id=726647
> Do you have a real use case for this?
For the 'hopefully bugs' variants, yes:
#1: Loop forever:
for i in xrange(x, sys.maxint, y)
That's a lot faster than
i = x
while True: ... i += y
#2: 'loop until optional upper bound':
def some_loop(start, end = sys.maxint):
for i in xrange(start, end, whatever())
> Do any real apps need to loop over more than
> sys.maxint integers?
The answer may be yes nowadays. Even my old
Solaris can find primes up to maxint/2 in just
2 hours. That's a loop over maxint/4 integers.
Though the remaining 3/4 come slower:-)
Still, I expect variants of the above code would
be less uncommon, like some_loop(-100).
> It would be ashamed to muckup the high
> performance implementation for something that
> does not arise in practice.
I hope you do not mean xrange(0, maxint, 3).
If you mean xrange(-100, maxint): Maybe xrange
could be split in several types (fast and slower)
and the xrange() operator would return one of
these, similar to how int() now can return long?
|
|
Date |
User |
Action |
Args |
2007-08-23 16:08:17 | admin | link | issue1003935 messages |
2007-08-23 16:08:17 | admin | create | |
|