Pyt*_*ous 9 ipython ipython-notebook
我在ipython笔记本(使用Chrome)中运行脚本,并注意到它比使用spyder作为我的IDE在Python中运行相同的脚本慢11倍.该脚本非常简单:它只是一组pandas数据帧上的循环和计算.没有输出打印到屏幕,也没有写入外部文件.我希望代码变慢,因为它没有矢量化,我很欣赏Ipython可能会涉及一些开销,但是11次......!你能想出任何理由吗?有什么建议?
谢谢!
我在我的机器上测试了这个,发现 ipython 实际上更快。
$ cat ex.py
import time
import numpy as np
now = time.time() #(seconds)
a = []
for j in range(2):
for s in range(10):
a.append(np.random.random())
then = now
print(time.time() - then)
$ python ex.py
0.142902851105
In [1]: %run ex.py
0.06136202812194824
Run Code Online (Sandbox Code Playgroud)
我敢打赌是你的 ipython 设置中的 Chrome 部分导致了速度变慢。