Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f6bcfdc

Browse files
[po] auto sync
1 parent ed5feac commit f6bcfdc

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

.stat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"translation": "90.61%", "updated_at": "2024-01-23T14:23:55Z"}
1+
{"translation": "90.62%", "updated_at": "2024-01-24T03:23:09Z"}

c-api/init.po

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

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

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

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

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

10131025
#: ../../c-api/init.rst:744
10141026
msgid ""

0 commit comments

Comments
 (0)