Skip to content

Instantly share code, notes, and snippets.

@kirang89
Created November 20, 2013 04:59
Show Gist options
  • Select an option

  • Save kirang89/7557980 to your computer and use it in GitHub Desktop.

Select an option

Save kirang89/7557980 to your computer and use it in GitHub Desktop.
The advantage in speed when using bit shifting
[kiran@Kirans-MacBook-Pro:~]
% python -m timeit 'x = 1 << 100000'
10000000 loops, best of 3: 0.0278 usec per loop
[kiran@Kirans-MacBook-Pro:~]
% python -m timeit 'x = pow(2,100000)'
1000 loops, best of 3: 334 usec per loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment