xrange question

Tim Peters tim.one at home.com
Tue May 8 05:10:58 CEST 2001

[John Flynn]
> ...
> Out of curiosity, at what point do you find that 'xrange' becomes
> most useful?

When and only when I'm writing a general function that I need to make
idiot-proof:  if someone may pass in 2000000000 as a loop bound, then
xrange() is the only way to go (at least until next year's machine's come out

BTW, stop worrying about this -- it's not worth it.  Even the "speed"
arguments are half bogus, as the relative speed of range(n) vs xrange(n)
historically varies across both n and platforms.  So pick one by flipping a
coin, stick with it, and feel free to blame me if it turns out you picked the
wrong one.

i-don't-mind-getting-blamed-is-entertaining<wink>-ly y'rs  - tim

More information about the Python-list mailing list