Skip to content

Instantly share code, notes, and snippets.

@indygreg
Created March 15, 2012 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indygreg/2040632 to your computer and use it in GitHub Desktop.
Save indygreg/2040632 to your computer and use it in GitHub Desktop.
strptime is slow
#!env python
from time import clock
from time import strptime
value = '2012-02-28 12:23:35Z'
fmt = '%Y-%m-%d %H:%M:%SZ'
total = 300000
start_time = clock()
for i in xrange(0, total):
strptime(value, fmt)
end_time = clock()
elapsed = end_time - start_time
print 'Elapsed: %f' % elapsed
print 'Rate: %f' % (total / elapsed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment