-
Notifications
You must be signed in to change notification settings - Fork 0
🌐 [translation-sync] Improve clarity and fix typos in need_for_speed lecture #50
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,31 +14,25 @@ translation: | |||||
| Major Scientific Libraries: 主要科学库 | ||||||
| Major Scientific Libraries::Why do we need them?: 为什么需要它们? | ||||||
| Major Scientific Libraries::Python's Scientific Ecosystem: Python 的科学生态系统 | ||||||
| Pure Python is slow: 纯 Python 速度慢 | ||||||
| Pure Python is slow::High vs low level code: 高级语言与低级语言 | ||||||
| Pure Python is slow::Where are the bottlenecks?: 瓶颈在哪里? | ||||||
| Pure Python is slow::Where are the bottlenecks?::Dynamic typing: 动态类型 | ||||||
| Pure Python is slow::Where are the bottlenecks?::Static types: 静态类型 | ||||||
| Pure Python is slow::Data Access: 数据访问 | ||||||
| Pure Python is slow::Data Access::Summing with Compiled Code: 使用编译代码求和 | ||||||
| Pure Python is slow::Data Access::Summing in Pure Python: 在纯 Python 中求和 | ||||||
| Pure Python is slow::Summary: 总结 | ||||||
| Why is Pure Python Slow?: 为什么纯 Python 速度较慢? | ||||||
| Why is Pure Python Slow?::Type Checking: 类型检查 | ||||||
| Why is Pure Python Slow?::Type Checking::Dynamic typing: 动态类型 | ||||||
| Why is Pure Python Slow?::Type Checking::Static types: 静态类型 | ||||||
| Why is Pure Python Slow?::Data Access: 数据访问 | ||||||
| Why is Pure Python Slow?::Data Access::Summing with Compiled Code: 使用编译代码求和 | ||||||
| Why is Pure Python Slow?::Data Access::Summing in Pure Python: 用纯 Python 求和 | ||||||
| Why is Pure Python Slow?::Summary: 总结 | ||||||
| Accelerating Python: 加速 Python | ||||||
| Accelerating Python::Vectorization: 向量化 | ||||||
| Accelerating Python::Vectorization vs for pure Python loops: 向量化 vs 纯 Python 循环 | ||||||
| Accelerating Python::Vectorization vs pure Python loops: 向量化 vs 纯 Python 循环 | ||||||
| Accelerating Python::JIT compilers: JIT 编译器 | ||||||
| Parallelization: 并行化 | ||||||
| Parallelization::Parallelization on CPUs: CPU 上的并行化 | ||||||
| Parallelization::Parallelization on CPUs::Multiprocessing: 多进程 | ||||||
| Parallelization::Parallelization on CPUs::Multithreading: 多线程 | ||||||
| Parallelization::Parallelization on CPUs::Advantages and Disadvantages: 优缺点 | ||||||
| Parallelization::Parallelization on CPUs::Multiprocessing: 多进程 | ||||||
| Parallelization::Parallelization on CPUs::Which Should We Use?: 应该选择哪种方式? | ||||||
| Parallelization::Hardware Accelerators: 硬件加速器 | ||||||
| Parallelization::Hardware Accelerators::GPUs and TPUs: GPU 和 TPU | ||||||
| Parallelization::Hardware Accelerators::Why TPUs/GPUs Matter: 为何 TPU/GPU 至关重要 | ||||||
| Parallelization::Single GPUs vs GPU Servers: 单 GPU 与 GPU 服务器 | ||||||
| Parallelization::Single GPUs vs GPU Servers::Single GPU Systems: 单 GPU 系统 | ||||||
| Parallelization::Single GPUs vs GPU Servers::Multi-GPU Servers: 多 GPU 服务器 | ||||||
| Parallelization::Summary: 总结 | ||||||
| Parallelization::Accessing GPU Resources: 访问 GPU 资源 | ||||||
| --- | ||||||
|
|
||||||
| (speed)= | ||||||
|
|
@@ -153,60 +147,44 @@ import random | |||||
| * Pandas 提供用于操作数据的类型和函数。 | ||||||
| * Numba 提供一个即时编译器,与 NumPy 配合良好,有助于加速 Python 代码。 | ||||||
|
|
||||||
| 我们将在本系列讲座中详细讨论所有这些库。 | ||||||
|
|
||||||
| ## 纯 Python 速度慢 | ||||||
|
|
||||||
| 如上所述,科学库的一大吸引力在于更快的执行速度。 | ||||||
|
|
||||||
| 我们将讨论科学库如何帮助我们加速代码。 | ||||||
|
|
||||||
| 对于这个主题,如果我们理解是什么导致了执行速度慢,将会很有帮助。 | ||||||
|
|
||||||
| ### 高级语言与低级语言 | ||||||
|
|
||||||
| 像 Python 这样的高级语言是为人类优化的。 | ||||||
|
|
||||||
| 这意味着程序员可以将许多细节留给运行时环境处理,例如: | ||||||
| 我们将在本系列讲座中广泛讨论所有这些库。 | ||||||
|
|
||||||
| * 指定变量类型 | ||||||
| * 内存分配与释放 | ||||||
| * 等等。 | ||||||
| ## 为什么纯 Python 速度较慢? | ||||||
|
|
||||||
| 此外,纯 Python 由一个[解释器](https://en.wikipedia.org/wiki/Interpreter_(computing))运行,该解释器逐条语句地执行代码。 | ||||||
| 如上所述,用纯 Python 编写的数值计算代码相对较慢。 | ||||||
|
|
||||||
| 这使得 Python 灵活、交互性强、易于编写、易于阅读,并且相对容易调试。 | ||||||
| 让我们尝试理解是什么导致了执行速度缓慢。 | ||||||
|
|
||||||
| 另一方面,Python 的标准实现(称为 CPython)无法与 C 或 Fortran 等编译语言的速度相媲美。 | ||||||
| ### 类型检查 | ||||||
|
|
||||||
| ### 瓶颈在哪里? | ||||||
| 纯 Python 操作中的一个开销来源是类型检查。 | ||||||
|
|
||||||
| 为什么会这样呢? | ||||||
| 让我们尝试理解其中的问题。 | ||||||
|
|
||||||
| #### 动态类型 | ||||||
|
|
||||||
| ```{index} single: Dynamic Typing | ||||||
| ``` | ||||||
|
|
||||||
| 考虑这个 Python 操作: | ||||||
| 考虑以下 Python 操作 | ||||||
|
|
||||||
| ```{code-cell} python3 | ||||||
| a, b = 10, 10 | ||||||
| a + b | ||||||
| ``` | ||||||
|
|
||||||
| 即使对于这个简单的操作,Python 解释器也有相当多的工作要做。 | ||||||
| 即使对于这个简单的操作,Python 解释器也需要做相当多的工作。 | ||||||
|
|
||||||
| 例如,在语句 `a + b` 中,解释器必须知道调用哪个操作。 | ||||||
| 例如,在语句 `a + b` 中,解释器必须知道应该调用哪种操作。 | ||||||
|
|
||||||
| 如果 `a` 和 `b` 是字符串,那么 `a + b` 需要字符串连接: | ||||||
| 如果 `a` 和 `b` 是字符串,那么 `a + b` 需要执行字符串拼接 | ||||||
|
||||||
| 如果 `a` 和 `b` 是字符串,那么 `a + b` 需要执行字符串拼接 | |
| 如果 `a` 和 `b` 是字符串,那么 `a + b` 需要执行字符串拼接: |
Copilot
AI
Apr 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
该行后面紧跟代码块,建议在句末补上用于引出示例的“:”,避免读起来像未完句。
| 如果 `a` 和 `b` 是列表,那么 `a + b` 需要执行列表拼接 | |
| 如果 `a` 和 `b` 是列表,那么 `a + b` 需要执行列表拼接: |
Copilot
AI
Apr 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“例如,考虑以下 C 代码,它计算从 1 到 10 的整数之和”后面直接进入代码块,建议在句末补上“:”以引出示例。
| 例如,考虑以下 C 代码,它计算从 1 到 10 的整数之和 | |
| 例如,考虑以下 C 代码,它计算从 1 到 10 的整数之和: |
Copilot
AI
Apr 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
该句后面接项目符号列表,建议在句末加“:”以引出下方要点,避免句子悬空。
| 在 C 或 Fortran 中,整数数组存储在一块连续的内存空间中 | |
| 在 C 或 Fortran 中,整数数组存储在一块连续的内存空间中: |
Copilot
AI
Apr 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
该句作为独立段落结尾缺少句号,建议补全中文标点以保持全文一致的书面表达。
| NumPy 使用类似的模型,灵感来源于 MATLAB | |
| NumPy 使用类似的模型,灵感来源于 MATLAB。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“考虑以下 Python 操作”后面紧跟代码块,当前缺少结尾标点(通常用“:”引出示例)。建议补上“:”以符合上下文的行文和排版习惯。