Re: range() is not the best way to check range?
- From: Leif K-Brooks <eurleif@xxxxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 22:59:47 -0400
Summercoolness@xxxxxxxxx wrote:
or is there an alternative use of range() or something similar that can
be as fast?
You could use xrange:
leif@ubuntu:~$ python -m timeit -n10000 "1 in range(10000)"
10000 loops, best of 3: 260 usec per loop
leif@ubuntu:~$ python -m timeit -n10000 "1 in xrange(10000)"
10000 loops, best of 3: 0.664 usec per loop
.
- Follow-Ups:
- Re: range() is not the best way to check range?
- From: Dan Bishop
- Re: range() is not the best way to check range?
- References:
- range() is not the best way to check range?
- From: Summercoolness
- range() is not the best way to check range?
- Prev by Date: Re: using capicom with python
- Next by Date: Re: question about what lamda does
- Previous by thread: Re: range() is not the best way to check range?
- Next by thread: Re: range() is not the best way to check range?
- Index(es):