Skip to content

Update p14_make_your_program_run_faster.rst #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/c14/p14_make_your_program_run_faster.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
选择一个复杂度为 O(n log n) 的算法要比你去调整一个复杂度为 O(n**2) 的算法所带来的性能提升要大得多。

如果你觉得你还是得进行优化,那么请从整体考虑。
作为一般准则,不要对程序的每一个部分都去优化,因为这些修改回导致代码难以阅读和理解
作为一般准则,不要对程序的每一个部分都去优化,因为这些修改会导致代码难以阅读和理解
你应该专注于优化产生性能瓶颈的地方,比如内部循环。

你还要注意微小优化的结果。例如考虑下面创建一个字典的两种方式:
Expand Down Expand Up @@ -240,6 +240,6 @@ Numba是一个在你使用装饰器来选择Python函数进行优化时的动态
这些函数会使用LLVM被编译成本地机器码。它同样可以极大的提升性能。
但是,跟PyPy一样,它对于Python 3的支持现在还停留在实验阶段。

最后我引用John Ousterhout说过的话作为结尾:“最好的性能优化时从不工作到工作状态的迁移”。
最后我引用John Ousterhout说过的话作为结尾:“最好的性能优化是从不工作到工作状态的迁移”。
直到你真的需要优化的时候再去考虑它。确保你程序正确的运行通常比让它运行更快要更重要一些(至少开始是这样的).