timeit
Alex Martelli
aleax at aleax.it
Sun Jun 15 13:49:41 EDT 2003
Bryan wrote:
> i tried timeit for the first time today, pretty darn impressive. i've
> noticed that postings in this newsgroup use timeit on the command line and
> with usually just one simple statement or loop.
Actually I also use it on the command line with several statements (on
Unix with the Bash shell making it convenient).
> is this the only way to
> use
> timeit?
No!
> can timeit be used within a script?
Of course. You can import it and use its Timer class.
> or to execute whole scripts?
> i guess the obvious anwer that one is:
>
> timeit -s"import myscript" "myscript.main()"
Of course, that's quite acceptable, too.
> i'm just curious how other are exploiting timeit.
So far I'm mostly using it from the command line, but the facilities
for using it as an imported module seem also excellent.
Alex
More information about the Python-list
mailing list