Dick Moores wrote:
I DID have setup code, the x=0. I now notice that if the x=0 is
not stated as the setup code, the time difference is enormous,
132-to-1 in this case.
python -m timeit -sx=0 while x100: x+=1
1000 loops, best of 3: 0.116 usec per loop
python -m timeit x=0 while
At 03:05 AM 10/3/2006, Kent Johnson wrote:
Dick Moores wrote:
I DID have setup code, the x=0. I now notice that if the x=0 is
not stated as the setup code, the time difference is enormous,
132-to-1 in this case.
python -m timeit -sx=0 while x100: x+=1
1000 loops, best of 3:
Dick Moores wrote:
At 03:05 AM 10/3/2006, Kent Johnson wrote:
timeit runs the setup code once, then runs the timed code many times
with the timer running. If x=0 is outside the loop, then the while
loop only runs once, because x == 100 after the first time through the
loop. So your first
At 04:35 AM 10/3/2006, Kent Johnson wrote:
Dick Moores wrote:
At 03:05 AM 10/3/2006, Kent Johnson wrote:
timeit runs the setup code once, then runs the timed code many times
with the timer running. If x=0 is outside the loop, then the while
loop only runs once, because x == 100 after the
Dick Moores wrote:
Very interesting. I thought a line of that template looked familiar.
I was seeing _t0 = _timer() regularly when I had the -s option set
without any setup:
C:\python -m timeit -r 3 -sfor x in range(1): x*x
Traceback (most recent call last):
File
At 05:54 AM 10/3/2006, Kent Johnson wrote:
Dick Moores wrote:
Very interesting. I thought a line of that template looked
familiar. I was seeing _t0 = _timer() regularly when I had the -s
option set without any setup:
C:\python -m timeit -r 3 -sfor x in range(1): x*x
Traceback (most recent
Dick Moores wrote:
At 05:54 AM 10/3/2006, Kent Johnson wrote:
Dick Moores wrote:
Very interesting. I thought a line of that template looked
familiar. I was seeing _t0 = _timer() regularly when I had the -s
option set without any setup:
C:\python -m timeit -r 3 -sfor x in range(1):
At 07:08 AM 10/3/2006, Kent Johnson wrote:
Dick Moores wrote:
At 05:54 AM 10/3/2006, Kent Johnson wrote:
Dick Moores wrote:
Very interesting. I thought a line of that template looked
familiar. I was seeing _t0 = _timer() regularly when I had the -s
option set without any setup:
Dick Moores wrote:
C:\python -m timeit -sx=0 while x100: x+=1
1000 loops, best of 3: 0.123 usec per loop
C:\python -m timeit -sfor x in range(100): x+=1
Traceback (most recent call last):
File E:\Python25\lib\runpy.py, line 95, in run_module
filename, loader, alter_sys)
At 03:08 AM 10/2/2006, Kent Johnson wrote:
Dick Moores wrote:
C:\python -m timeit -sx=0 while x100: x+=1
1000 loops, best of 3: 0.123 usec per loop
C:\python -m timeit -sfor x in range(100): x+=1
Traceback (most recent call last):
File E:\Python25\lib\runpy.py, line 95,
At 01:50 PM 10/2/2006, John Fouhy wrote:
On 02/10/06, Dick Moores [EMAIL PROTECTED] wrote:
C:\python -m timeit -sfor x in range(100): x+=1
Traceback (most recent call last):
The -s option specifies the setup code. In this case, you don't have
any setup code. Try this:
python -m timeit for
C:\python -m timeit -sx=0 while x100: x+=1
1000 loops, best of 3: 0.123 usec per loop
C:\python -m timeit -sfor x in range(100): x+=1
Traceback (most recent call last):
File E:\Python25\lib\runpy.py, line 95, in run_module
filename, loader, alter_sys)
File
12 matches
Mail list logo