Skip to content

Instantly share code, notes, and snippets.

@chaosong
Created October 28, 2013 07:15
Show Gist options
  • Save chaosong/7192556 to your computer and use it in GitHub Desktop.
Save chaosong/7192556 to your computer and use it in GitHub Desktop.
python snippets
#!/usr/bin/env python
# coding=utf8
import sys
import time
reload(sys)
sys.setdefaultencoding('utf8')
def timeit(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
print >> sys.stderr, '%r %2.2f sec' % (method.__name__, te - ts)
return result
return timed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment