why I don't like range/xrange
Bjoern Schliessmann
usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Fri Feb 16 12:43:04 EST 2007
stdazi wrote:
> Many times I was suggested to use xrange and range instead of the
> while constructs, and indeed, they are quite more elegant - but,
> after calculating the overhead (and losen flexibility) when
> working with range/xrange, and while loops, you get to the
> conclusion that it isn't really worth using range/xrange loops.
How did you calculate that?
> b) xrange long int overflow :
>
> for i in xrange(0, 1 << len(S)) :
> ........
> OverflowError: long int too large to convert to int
Why do you bit shift a len result here? Just to get a huge number?
Try the same with C. You'd get an integer overflow in the first
place.
But this long int => int issue should not exist in a future python
version any more, IIRC int and long int is scheduled to be merged
somehow. (Or isn't it?)
Regards,
Björn
--
BOFH excuse #203:
Write-only-memory subsystem too slow for this machine. Contact your
local dealer.
More information about the Python-list
mailing list