2的(幂)n次方实现方式比较

来源:互联网 发布:seo求职简历 编辑:程序博客网 时间:2024/06/05 08:41

发现<< 居然比** 还要快那么点点,记录之~


In [613]: %timeit 1 << 10The 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 loopIn [614]: %timeit 2 ** 10100000000 loops, best of 3: 19.7 ns per loopIn [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
原创粉丝点击