Skip to content
Open
Show file tree
Hide file tree
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 .translate/state/python_advanced_features.md.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source-sha: f791129259d11c138d7662c88f994c9d5ebaa875
synced-at: "2026-03-25"
source-sha: dcf952a9a05ba3bf8763c21d89dac3c7480b8d45
synced-at: "2026-03-26"
model: claude-sonnet-4-6
mode: UPDATE
section-count: 7
Expand Down
4 changes: 2 additions & 2 deletions lectures/python_advanced_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -582,14 +582,14 @@ add(1.5, 2.7)

1. **可读性**:类型提示使函数签名具有自文档化效果。读者可以立即了解函数期望的输入类型和返回类型。
2. **编辑器支持**:VS Code 等 IDE 利用类型提示提供更好的自动补全、错误检测和内联文档功能。
3. **错误检查**:[mypy](https://mypy.readthedocs.io/) 和 [pyrefly](https://pyrefly.org/) 等工具通过分析类型提示,在*运行代码之前*就能发现错误。
3. **错误检查**:[mypy](https://mypy.readthedocs.io/en/stable/) 和 [pyrefly](https://pyrefly.org/) 等工具通过分析类型提示,在*运行代码之前*就能发现错误。
4. **LLM 生成的代码**:大型语言模型经常生成带有类型提示的代码,因此理解其语法有助于阅读和使用它们的输出。

### 科学 Python 中的类型提示

类型提示与 {doc}`性能需求 <need_for_speed>` 的讨论密切相关:

* [JAX](https://jax.readthedocs.io/) 和 [Numba](https://numba.pydata.org/) 等高性能库依赖于了解变量类型来编译快速的机器码。
* [JAX](https://docs.jax.dev/en/latest/) 和 [Numba](https://numba.pydata.org/) 等高性能库依赖于了解变量类型来编译快速的机器码。
* 虽然这些库在运行时推断类型,而不是直接读取 Python 类型提示,但*概念*是相同的——显式的类型信息能够实现优化。
* 随着 Python 生态系统的发展,类型提示与性能工具之间的联系预计将进一步加强。

Expand Down
Loading