IPython:关闭关于 "This could mean that an intermediate result is being cached" 的 %timeit 消息

IPython: turn off %timeit message about "This could mean that an intermediate result is being cached"

自从升级到IPython版本3(我有3.1.0),每次我使用%timeit命令,它都会在打印计时结果之前打印"The slowest run took [number] times longer than the fastest. This could mean that an intermediate result is being cached"。即使对于非常简单的操作也会发生这种情况。例如:

In [4]: x = 5

In [5]: %timeit x
The slowest run took 53.99 times longer than the fastest. This could mean that an intermediate result is being cached 
100000000 loops, best of 3: 19.8 ns per loop

和:

In [17]: %timeit 22 + 1
The slowest run took 106.15 times longer than the fastest. This could mean that an intermediate result is being cached 
100000000 loops, best of 3: 12.2 ns per loop

只有少数情况我可以让它不发生,例如:

In [15]: %timeit 5
100000000 loops, best of 3: 8.37 ns per loop

我知道可能在某种程度上进行了一些缓存(例如 中所解释的),但该消息会让人分心并且并不是很有用。有什么方法可以关闭它吗?

%timeit -q会无声,-o选项会return结果。这略有不同,但应该可以解决问题。