在测试struct.pack
的性能时,我得到以下结果:
In [3]: %timeit pack('dddd', 1.0, 1.0, 1.0, 1.0)
The slowest run took 578.59 times longer than the fastest. This could
mean that an intermediate result is being cached
1000000 loops, best of 3: 197 ns per loop
为什么最慢的运行速度慢578倍?包执行一些内部缓存,或者这是某种CPU级别缓存的结果,还是其他什么?