我刚刚尝试使用 Jython (2.5.1) 运行 BeautifulSoup (3.1.0.1),我惊讶地发现它比 CPython 慢了多少。使用 CPython解析页面 ( http://www.fixprotocol.org/specifications/fields/5000-5999 ) 只需不到一秒(准确地说是 0.844 秒)。使用 Jython 需要 564 秒 - 几乎是 700 倍。
谁能证实这个结果?Jython 的运行速度比 CPython 慢 700 倍似乎是不合理的。也许我的设置有问题。
[编辑] 这是我用来测试的代码(当然我下载了上面提到的 HTML 文件):
import time
from BeautifulSoup import BeautifulSoup
data = open("fix-5000-5999.html").read()
start = time.time()
soup = BeautifulSoup(data)
print time.time() - start