john-science / python_for_scientists

Python Open Courseware for Scientists and Engineers
GNU General Public License v3.0
68 stars 40 forks source link

Improve timeit Section #34

Closed john-science closed 5 years ago

john-science commented 9 years ago

This works:

from datetime import datetime
from timeit import timeit
timeit(str(datetime.now().strftime('%Y')), number=10)

but this doesn't:

from datetime import datetime
from timeit import timeit
timeit(str(datetime.now()), number=10)

There are some details about timeit that I need to add to the lecture.