$ python -mtimeit 'pow(2,64)'
1000000 loops, best of 3: 1.18 usec per loop
12:31 AM:senthil@:~
$ python -mtimeit 'getattr(1,"__lshift__")(64)'
1000000 loops, best of 3: 0.356 usec per loop
12:32 AM:senthil@:~
I don't know the reason for this difference, I shall update the post when i find out why.
3 comments:
It makes sense in C/C++ where bitwise manipulations are fast. Dont know what can be the reason for python ?
Any reason you don't use the shorter, more obvious and 15 times faster 1<<64 or 2**64 ?
it's your function lookup that's taking the time.
Post a Comment