range() is not the best way to check range?
Summercoolness at gmail.com
Summercoolness at gmail.com
Tue Jul 18 17:25:18 EDT 2006
Summercoolness at gmail.com wrote:
> it seems that range() can be really slow:
>
> if i in range (0, 10000):
My original use was like this:
if i in range (iStart, iEnd):
listData.append(a)
in which iStart is 1000 and iEnd is 1008
so in that case, the program ran fine...
but later on, i wanted to include all data, so I relaxed the range by
setting iStart to 0 and iEnd to 9999 and later on i found that the
program was slow due to this.
So looks like the usage of
if sDay in ("Tue", "Wed", "Thu"):
is more like good use of "in a list" but in range(0,10000) will be a
big search in a list.
More information about the Python-list
mailing list