简体   繁体   English

计算时间Python【Python数据分析3E】

[英]Computing time in Python [Python for Data Analysis 3E]

In Chapter 4 of Python for Data Analysis 3E , it shows the following example and claims that numpy should be much faster.数据分析 3E 的 Python 的第 4 章中,它显示了以下示例并声称 numpy 应该更快。

在此处输入图像描述

However, when I tried it myself, I got very different results as circled below where numpy actually takes longer time.然而,当我自己尝试时,我得到了非常不同的结果,如下图所示,其中 numpy 实际上需要更长的时间。 Could anyone help clarify what the author means in the book, please?请问谁能帮忙解释一下作者在书中的意思吗?

在此处输入图像描述

You should read the actual results, not what you circled.您应该阅读实际结果,而不是圈出的内容。 NumPy was faster, 0.9 ms vs 55.6 ms. NumPy 更快,分别为 0.9 毫秒和 55.6 毫秒。 The benchmark for NumPy took longer because it repeated 100x more often (1000 loops instead of 10 loops). NumPy 的基准测试花费了更长的时间,因为它重复的次数增加了 100 倍(1000 次循环而不是 10 次循环)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM