8000 [po] auto sync · python/python-docs-zh-cn@7dac9a3 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 7dac9a3

Browse files
[po] auto sync
1 parent c6eda53 commit 7dac9a3

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.stat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"translation": "89.97%", "updated_at": "2024-01-23T15:09:19Z"}
1+
{"translation": "89.98%", "updated_at": "2024-01-24T03:09:16Z"}

c-api/init.po

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,9 @@ msgid ""
927927
"released around potentially blocking I/O operations like reading or writing "
928928
"a file, so that other Python threads can run in the meantime."
929929
msgstr ""
930+
"因此,规则要求只有获得 :term:`GIL` 的线程才能在 Python对象上执行操作或调用 Python/C API 函数。 "
931+
"为了模拟并发执行,解释器会定期尝试切换线程 (参见 :func:`sys.setswitchinterval`)。 锁也会在读写文件等可能造成阻塞的 "
932+
"I/O 操作时释放,以便其他 Python 线程可以同时运行。"
930933

931934
#: ../../c-api/init.rst:672
932935
msgid ""
@@ -935,6 +938,8 @@ msgid ""
935938
"global variable pointing to the current :c:type:`PyThreadState`: it can be "
936939
"retrieved using :c:func:`PyThreadState_Get`."
937940
msgstr ""
941+
"Python 解释器会在一个名为 :c:type:`PyThreadState` 的数据结构体中保存一些线程专属的记录信息。 还有一个全局变量指向当前的"
942+
" :c:type:`PyThreadState`: 它可以使用 :c:func:`PyThreadState_Get` 来获取。"
938943

939944
#: ../../c-api/init.rst:678
940945
msgid "Releasing the GIL from extension code"
@@ -973,6 +978,8 @@ msgid ""
973978
"variable). Conversely, when acquiring the lock and restoring the thread "
974979
"state, the lock must be acquired before storing the thread state pointer."
975980
msgstr ""
981+
"这些函数的工作原理如下:全局解释器锁被用来保护指向当前线程状态的指针。 当释放锁并保存线程状态时,必须在锁被释放之前获取当前线程状态指针 "
982+
"(因为另一个线程可以立即获取锁并将自己的线程状态存储到全局变量中)。 相应地,当获取锁并恢复线程状态时,必须在存储线程状态指针之前先获取锁。"
976983

977984
#: ../../c-api/init.rst:724
978985
msgid ""
@@ -983,6 +990,9 @@ msgid ""
983990
"standard :mod:`zlib` and :mod:`hashlib` modules release the GIL when "
984991
"compressing or hashing data."
985992
msgstr ""
993+
"调用系统 I/O 函数是释放 GIL 的最常见用例,但它在调用不需要访问 Python "
994+
"对象的长期运行计算,比如针对内存缓冲区进行操作的压缩或加密函数之前也很有用。 举例来说,在对数据执行压缩或哈希操作时标准 :mod:`zlib` 和 "
995+
":mod:`hashlib` 模块就会释放 GIL。"
986996

987997
#: ../../c-api/init.rst:735
988998
msgid "Non-Python created threads"
@@ -997,6 +1007,8 @@ msgid ""
9971007
"management), they don't hold the GIL, nor is there a thread state structure "
9981008
"for them."
9991009
msgstr ""
1010+
"当使用专门的 Python API(如 :mod:`threading` 模块)创建线程时,会自动关联一个线程状态因而上面显示的代码是正确的。 "
1011+
"但是,如果线程是用 C 创建的(例如由具有自己的线程管理的第三方库创建),它们就不持有 GIL 也没有对应的线程状态结构体。"
10001012

10011013
#: ../../c-api/init.rst:744
10021014
msgid ""

0 commit comments

Comments
 (0)
0