Skip to content

Instantly share code, notes, and snippets.

@mahmoud
Created November 19, 2012 09:45
Show Gist options
  • Save mahmoud/4109868 to your computer and use it in GitHub Desktop.
Save mahmoud/4109868 to your computer and use it in GitHub Desktop.
partial() performance
#super basic
$ python -m timeit -s 'def inc(x=1): return x+1' 'inc()'
10000000 loops, best of 3: 0.0785 usec per loop
$ python -m timeit -s "from functools import partial
> def inc(x=1): return x+1
> inc = partial(inc, 1)" 'inc()'
10000000 loops, best of 3: 0.0922 usec per loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment