Why is it faster the second time ?
Philip Semanchuk
philip at semanchuk.com
Sun Jan 25 21:55:29 EST 2009
On Jan 23, 2009, at 12:46 PM, jalanb3 wrote:
> 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 ?
Lots of things could be involved. For instance, your OS probably
memory cached all of the files involved during the first run, so all
subsequent runs needed no disk I/O.
More information about the Python-list
mailing list