range() is not the best way to check range?
Andy Dingley
dingbat at codesmiths.com
Tue Jul 18 06:54:51 EDT 2006
Summercoolness at gmail.com wrote:
> it seems that range() can be really slow:
> if i in range (0, 10000):
RTFM on range()
You're completely mis-using it here, using it with an if ... in ...
test. The purpose of range() in Python is as loop control, not
comparisons! It's not a SQL BETWEEN statement.
Although you _can_ do this (you've done it!) you've also found that
it's slow. Many people would argue that even using range() for loop
control is unusably slow.
More information about the Python-list
mailing list