Skip to content

Instantly share code, notes, and snippets.

@bulv1ne
Created September 19, 2013 18:37
Show Gist options
  • Save bulv1ne/6627905 to your computer and use it in GitHub Desktop.
Save bulv1ne/6627905 to your computer and use it in GitHub Desktop.
timeit.timeit('x()', setup='''
def create_constant(value):
return itertools.repeat(value).next
x=create_constant("")
''')
#0.13626525126508682
timeit.timeit('x()', setup='def x(): ""')
#0.17869136946876552
timeit.timeit('x()', setup='x = lambda: ""')
#0.18088355837787162
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment