2的n次冪
<< 是最快的執行方法,移位操作符。
In [613]: %timeit 1 << 10
The slowest run took 78.83 times longer than the fastest. This could mean that an intermediate result is being cached.
100000000 loops, best of 3: 19.5 ns per loop
In [614]: %timeit 2 ** 10
100000000 loops, best of 3: 19.7 ns per loop
In [615]: %timeit pow(2, 10)
The slowest run took 6.41 times longer than the fastest. This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 601 ns per loop