I have some log parsing code that needs to turn a timestamp into a datetime object. I am using datetime.strptime but this function is using a lot of cputime according to cPr
What's a "lot of time"? strptime is taking about 30 microseconds here:
strptime
from datetime import datetime import timeit def f(): datetime.strptime("01/Nov/2010:07:49:33", "%d/%b/%Y:%H:%M:%S") n = 100000 print "%.6f" % (timeit.timeit(f, number=n)/n)
prints 0.000031.