Last active
December 17, 2015 03:09
-
-
Save dogancelik/5541173 to your computer and use it in GitHub Desktop.
(Python) timeit for zeroing time attributes in a datetime object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
t = timeit.Timer(stmt="datetime.datetime(*datetime.datetime.now().date().timetuple()[:6])", setup="import datetime") | |
print t.timeit() # 4.80428367916 | |
t = timeit.Timer(stmt="datetime.datetime.combine(datetime.datetime.now().date(), datetime.time(0, 0, 0))", setup="import datetime") | |
print t.timeit() # 3.23761676673 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment