When trying to use the Python built-in module ‘timeit’ as follows:
timeit.Timer('print "hi"').timeit()
it prints more than one line; why is that? It keeps printing “hi” endlessly:
hi
hi
hi
hi
...
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
timeitis designed to test extremely short code snippets, so it runs the code many times and averages them. As a default, it runs it 1000000 times.You can change this by running it as follows: