脚本在不同计算机上的执行时间(python 3.5,miniconda)

Script execution time on different computers (python 3.5, miniconda)

我遇到了以下问题:在计算机(2 号)上的脚本执行时间明显大于在另一台计算机(计算机 1)上的执行时间。

我使用 Python 来处理 Excel 个文件。 我为这三个库导入:

为什么执行时间不同?我该如何解决?

它在单核上运行,计算机 1 具有更高的时钟速率 = 更快的单线程处理。

如评论中所述,Python 使用 Global Interpreter Lock (GIL)。正如 Wiki 上所述:"An interpreter that uses GIL always allows exactly one thread to execute at a time, even if run on a multi-core processor".

您的 i3 处理器可能 'only' 有 4 个内核而不是 i7 中的 8 个内核,但是 Python 一次只会使用 1 个线程:因此内核越快,您的处理器越快脚本被执行。正如 this page 中所解释的那样:"The CPU speed determines how many calculations it can perform in one second of time. The higher the speed, the more calculations it can perform, thus making the computer faster."