Why is it faster the second time ?

jalanb3 yahoo at al-got-rhythm.net
Fri Jan 23 12:46:48 EST 2009


Hello the group,

I am wondering why doctests run slower the first time.
In the transcript below "try" is a script which finds and runs
doctests in the current directory. It also shows how long it takes to
run these tests.

I added a new test which searches recursively for files given a path,
and it took (approx) 3 seconds to run. But all subsequent runs take
less than half a second.

Am I right in thinking that the extra time on the first run is the
time it takes to compile .py -> .pyc ?

Transcript follows

$ try paths.test

try ./paths.test; 10 tests passed in 3 seconds
10 tests passed, 0 failed, in 3 seconds

$ try paths.test

try ./paths.test; 10 tests passed very quickly
10 tests passed, 0 failed, in 0 seconds

$ try paths.test

try ./paths.test; 10 tests passed very quickly
10 tests passed, 0 failed, in 0 seconds

-- 
Alan




More information about the Python-list mailing list