File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- {"translation" : " 93.32%" , "updated_at" : " 2024-01-24T02:56:00Z " }
1+ {"translation" : " 93.32%" , "updated_at" : " 2024-01-24T03:55:56Z " }
Original file line number Diff line number Diff line change @@ -1257,6 +1257,8 @@ msgid ""
12571257"variable). Conversely, when acquiring the lock and restoring the thread "
12581258"state, the lock must be acquired before storing the thread state pointer."
12591259msgstr ""
1260+ "这些函数的工作原理如下:全局解释器锁被用来保护指向当前线程状态的指针。 当释放锁并保存线程状态时,必须在锁被释放之前获取当前线程状态指针 "
1261+ "(因为另一个线程可以立即获取锁并将自己的线程状态存储到全局变量中)。 相应地,当获取锁并恢复线程状态时,必须在存储线程状态指针之前先获取锁。"
12601262
12611263#: ../../c-api/init.rst:917
12621264msgid ""
@@ -1267,6 +1269,9 @@ msgid ""
12671269"standard :mod:`zlib` and :mod:`hashlib` modules release the GIL when "
12681270"compressing or hashing data."
12691271msgstr ""
1272+ "调用系统 I/O 函数是释放 GIL 的最常见用例,但它在调用不需要访问 Python "
1273+ "对象的长期运行计算,比如针对内存缓冲区进行操作的压缩或加密函数之前也很有用。 举例来说,在对数据执行压缩或哈希操作时标准 :mod:`zlib` 和 "
1274+ ":mod:`hashlib` 模块就会释放 GIL。"
12701275
12711276#: ../../c-api/init.rst:928
12721277msgid "Non-Python created threads"
@@ -1281,6 +1286,8 @@ msgid ""
12811286"management), they don't hold the GIL, nor is there a thread state structure "
12821287"for them."
12831288msgstr ""
1289+ "当使用专门的 Python API(如 :mod:`threading` 模块)创建线程时,会自动关联一个线程状态因而上面显示的代码是正确的。 "
1290+ "但是,如果线程是用 C 创建的(例如由具有自己的线程管理的第三方库创建),它们就不持有 GIL 也没有对应的线程状态结构体。"
12841291
12851292#: ../../c-api/init.rst:937
12861293msgid ""
You can’t perform that action at this time.
0 commit comments