From 60c2723cf66970157d703bcbdb816e385734d0af Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Sat, 9 Dec 2023 15:37:23 +0800 Subject: [PATCH 1/3] translate library/multiprocessing.shared_memory.po --- library/multiprocessing.shared_memory.po | 116 ++++++++++++++++++++--- 1 file changed, 102 insertions(+), 14 deletions(-) diff --git a/library/multiprocessing.shared_memory.po b/library/multiprocessing.shared_memory.po index da0cb02aac..dd63ea6ffc 100644 --- a/library/multiprocessing.shared_memory.po +++ b/library/multiprocessing.shared_memory.po @@ -1,15 +1,15 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2023, Python Software Foundation # This file is distributed under the same license as the Python package. -# FIRST AUTHOR , YEAR. # +# Translators: +# Matt Wang , 2023 msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-26 00:03+0000\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" +"PO-Revision-Date: 2023-12-11 00:03+0800\n" +"Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -22,6 +22,7 @@ msgid "" ":mod:`multiprocessing.shared_memory` --- Shared memory for direct access " "across processes" msgstr "" +":mod:`multiprocessing.shared_memory` --- 對於共享記憶體的跨行程直接存取" #: ../../library/multiprocessing.shared_memory.rst:7 msgid "**Source code:** :source:`Lib/multiprocessing/shared_memory.py`" @@ -37,6 +38,11 @@ msgid "" "`SharedMemoryManager`, is also provided in the ``multiprocessing.managers`` " "module." msgstr "" +"該模組提供了一個 :class:`SharedMemory` 類別,用於分配和管理被多核心或對稱多處" +"理器 (symmetric multiprocessor, SMP) 機器上的一個或多個行程存取的共享記憶體。" +"為了協助共享記憶體的生命週期管理,特別是跨不同行程的管理,``multiprocessing." +"managers`` 模組中還提供了一個 :class:`~multiprocessing.managers.BaseManager` " +"子類別 :class:`SharedMemoryManager`。" #: ../../library/multiprocessing.shared_memory.rst:26 msgid "" @@ -52,6 +58,13 @@ msgid "" "via disk or socket or other communications requiring the serialization/" "deserialization and copying of data." msgstr "" +"在此模組中,共享記憶體是指「System V 風格」的共享記憶體區塊(儘管不一定如此明" +"確實作),而不是指「分散式共享記憶體 (distributed shared memory)」。這種型別" +"的共享記憶體允許不同的行程潛在地讀取和寫入易失性記憶體 (volatile memory) 的公" +"開(或共享)區域。通常行程只能存取自己的行程記憶體空間,但共享記憶體允許在行" +"程之間共享資料,從而避免了在包含該資料的行程之間發送訊息的需求。與透過硬碟或 " +"socket 或其他需要序列化/還原序列化 (serialization/deserialization) 和複製資料" +"的通訊方式以共享資料相比,直接透過記憶體共享資料可以提供顯著的性能優勢。" #: ../../library/multiprocessing.shared_memory.rst:41 msgid "" @@ -61,6 +74,9 @@ msgid "" "different process can attach to that same shared memory block using that " "same name." msgstr "" +"建立新的共享記憶體區塊或附加到現有的共享記憶體區塊。每個共享記憶體區塊都被分" +"配了一個唯一的名稱。透過這種方式,一個行程可以建立具有特定名稱的共享記憶體區" +"塊,而不同的行程可以使用該相同名稱附加到同一共享記憶體區塊。" #: ../../library/multiprocessing.shared_memory.rst:47 msgid "" @@ -71,6 +87,10 @@ msgid "" "block is no longer needed by any process, the :meth:`unlink()` method should " "be called to ensure proper cleanup." msgstr "" +"作為跨行程共享資料的資源,共享記憶體區塊的壽命可能比建立它們的原始行程還要" +"長。當一個行程不再需要存取但其他行程可能仍需要的共享記憶體區塊時,應該呼叫 :" +"meth:`close()` 方法。當任何行程不再需要共享記憶體區塊時,應呼叫 :meth:" +"`unlink()` 方法以確保正確清理。" #: ../../library/multiprocessing.shared_memory.rst:54 msgid "" @@ -78,12 +98,16 @@ msgid "" "string. When creating a new shared memory block, if ``None`` (the default) " "is supplied for the name, a novel name will be generated." msgstr "" +"*name* 是所請求的共享記憶體的唯一名稱,指定為字串。建立新的共享記憶體區塊時," +"如果名稱提供為 ``None``\\ (預設值),則會生成一個新的名稱。" #: ../../library/multiprocessing.shared_memory.rst:58 msgid "" "*create* controls whether a new shared memory block is created (``True``) or " "an existing shared memory block is attached (``False``)." msgstr "" +"*create* 控制是否建立新的共享記憶體區塊 (``True``) 或附加現有的共享記憶體區" +"塊 (``False``)。" #: ../../library/multiprocessing.shared_memory.rst:61 msgid "" @@ -93,6 +117,10 @@ msgid "" "memory block may be larger or equal to the size requested. When attaching " "to an existing shared memory block, the ``size`` parameter is ignored." msgstr "" +"*size* 指定了建立新共享記憶體區塊時請求的位元組數。由於某些平台會根據該平台的" +"記憶體頁 (memory page) 大小來選擇分配記憶體區塊,因此共享記憶體區塊的確切大小" +"可能大於或等於請求的大小。當附加到現有共享記憶體區塊時,``size`` 參數將被忽" +"略。" #: ../../library/multiprocessing.shared_memory.rst:69 msgid "" @@ -101,6 +129,9 @@ msgid "" "instance is no longer needed. Note that calling ``close()`` does not cause " "the shared memory block itself to be destroyed." msgstr "" +"關閉從此實例對共享記憶體的存取。為了確保正確清理資源,一旦實例不再被需要,所" +"有實例都應該呼叫 ``close()``。請注意,呼叫 ``close()`` 不會使得共享記憶體區塊" +"本身被銷毀。" #: ../../library/multiprocessing.shared_memory.rst:77 msgid "" @@ -114,24 +145,29 @@ msgid "" "relinquishing its hold on a shared memory block may call ``unlink()`` and :" "meth:`close()` in either order." msgstr "" +"請求銷毀底層共享記憶體區塊。為了確保正確清理資源,應該在需要共享記憶體區塊的" +"所有行程中呼叫一次(且僅一次)\\ ``unlink()``。請求銷毀後,共享記憶體區塊可能" +"會也可能不會立即銷毀,此行為可能因平台而異。呼叫 ``unlink()`` 後嘗試存取共享" +"記憶體區塊內的資料可能會導致記憶體存取錯誤。注意:最後一個放棄持有某共享記憶" +"體區塊的行程可以按任意順序呼叫 ``unlink()`` 和 :meth:`close()`。" #: ../../library/multiprocessing.shared_memory.rst:90 msgid "A memoryview of contents of the shared memory block." -msgstr "" +msgstr "共享記憶體區塊內容的記憶體視圖 (memoryview)。" #: ../../library/multiprocessing.shared_memory.rst:94 msgid "Read-only access to the unique name of the shared memory block." -msgstr "" +msgstr "對共享記憶體區塊之唯一名稱的唯讀存取。" #: ../../library/multiprocessing.shared_memory.rst:98 msgid "Read-only access to size in bytes of the shared memory block." -msgstr "" +msgstr "對共享記憶體區塊大小(以位元組為單位)的唯讀存取。" #: ../../library/multiprocessing.shared_memory.rst:101 msgid "" "The following example demonstrates low-level use of :class:`SharedMemory` " "instances::" -msgstr "" +msgstr "以下範例示範了 :class:`SharedMemory` 實例的低階使用方式:: :" #: ../../library/multiprocessing.shared_memory.rst:127 msgid "" @@ -139,12 +175,16 @@ msgid "" "`SharedMemory` class with `NumPy arrays `_, accessing " "the same ``numpy.ndarray`` from two distinct Python shells:" msgstr "" +"以下範例示範了 :class:`SharedMemory` 類別與 `NumPy 陣列 `_\\ 的實際用法:從兩個不同的 Python shell 存取相同的 ``numpy.ndarray``:" #: ../../library/multiprocessing.shared_memory.rst:181 msgid "" "A subclass of :class:`~multiprocessing.managers.BaseManager` which can be " "used for the management of shared memory blocks across processes." msgstr "" +":class:`~multiprocessing.managers.BaseManager` 的子類別,可用於跨行程管理共享" +"記憶體區塊。" #: ../../library/multiprocessing.shared_memory.rst:184 msgid "" @@ -159,6 +199,13 @@ msgid "" "instances through a ``SharedMemoryManager``, we avoid the need to manually " "track and trigger the freeing of shared memory resources." msgstr "" +"在 :class:`SharedMemoryManager` 實例上呼叫 :meth:`~multiprocessing.managers." +"BaseManager.start` 會啟動一個新行程。這個新行程的唯一目的是管理那些透過它建立" +"出的所有共享記憶體區塊的生命週期。要觸發釋放該行程管理的所有共享記憶體區塊," +"請在實例上呼叫 :meth:`~multiprocessing.managers.BaseManager.shutdown()`,這會" +"觸發對該行程管理的所有 :class:`SharedMemory` 物件的 :meth:`SharedMemory." +"unlink()` 呼叫,然後再停止這個行程。透過 ``SharedMemoryManager`` 建立 " +"``SharedMemory`` 實例,我們無需手動追蹤和觸發共享記憶體資源的釋放。" #: ../../library/multiprocessing.shared_memory.rst:196 msgid "" @@ -166,6 +213,8 @@ msgid "" "instances and for creating a list-like object (:class:`ShareableList`) " "backed by shared memory." msgstr "" +"此類別提供了用於建立和回傳 :class:`SharedMemory` 實例以及建立由共享記憶體支援" +"的類串列物件 (:class:`ShareableList`) 的方法。" #: ../../library/multiprocessing.shared_memory.rst:200 msgid "" @@ -174,24 +223,31 @@ msgid "" "may be used to connect to an existing ``SharedMemoryManager`` service from " "other processes." msgstr "" +"請參閱 :class:`multiprocessing.managers.BaseManager` 了解繼承的 *address* 和 " +"*authkey* 可選輸入引數的描述以及如何使用它們從其他行程連接到現有的 " +"``SharedMemoryManager`` 服務。" #: ../../library/multiprocessing.shared_memory.rst:207 msgid "" "Create and return a new :class:`SharedMemory` object with the specified " "``size`` in bytes." msgstr "" +"建立並回傳一個新的 :class:`SharedMemory` 物件,該物件具有指定的 ``size``\\ " +"(以位元組為單位)。" #: ../../library/multiprocessing.shared_memory.rst:212 msgid "" "Create and return a new :class:`ShareableList` object, initialized by the " "values from the input ``sequence``." msgstr "" +"建立並回傳一個新的 :class:`ShareableList` 物件,該物件由輸入 ``sequence`` 中" +"的值初始化。" #: ../../library/multiprocessing.shared_memory.rst:216 msgid "" "The following example demonstrates the basic mechanisms of a :class:" "`SharedMemoryManager`:" -msgstr "" +msgstr "以下範例示範了 :class:`SharedMemoryManager` 的基本作用機制:" #: ../../library/multiprocessing.shared_memory.rst:234 msgid "" @@ -200,6 +256,8 @@ msgid "" "to ensure that all shared memory blocks are released after they are no " "longer needed:" msgstr "" +"以下範例描述了一種可能更方便的模式,即透過 :keyword:`with` 陳述式使用 :class:" +"`SharedMemoryManager` 物件,以確保所有共享記憶體區塊不再被需要後都被釋放:" #: ../../library/multiprocessing.shared_memory.rst:253 msgid "" @@ -207,6 +265,9 @@ msgid "" "the shared memory blocks created using that manager are all released when " "the :keyword:`with` statement's code block finishes execution." msgstr "" +"在 :keyword:`with` 陳述式中使用 :class:`SharedMemoryManager` 時,當 :keyword:" +"`with` 陳述式的程式碼區塊執行完畢時,使用該管理器建立的共享記憶體區塊都會被釋" +"放。" #: ../../library/multiprocessing.shared_memory.rst:260 msgid "" @@ -219,6 +280,12 @@ msgid "" "no append, insert, etc.) and do not support the dynamic creation of new :" "class:`ShareableList` instances via slicing." msgstr "" +"提供一個類似串列的可變物件,其中有被儲存的所有值都儲存在共享記憶體區塊中。這" +"限制了可存儲的值只能夠是內建資料型別 ``int``\\ (帶符號的 64 位元 (signed 64-" +"bit))、``float``、``bool``、``str``\\ (編碼為 utf-8 時個別小於 10M 位元" +"組)、``bytes``\\ (個別小於 10M 位元組)和 ``None``。它還與內建的 ``list`` " +"型別有顯著不同,因為這些串列不能更改其總長度(即不能追加 (append)、插入等)," +"並且不支援透過切片動態建立新的 :class:`ShareableList` 實例。" #: ../../library/multiprocessing.shared_memory.rst:270 msgid "" @@ -226,6 +293,8 @@ msgid "" "to ``None`` to instead attach to an already existing ``ShareableList`` by " "its unique shared memory name." msgstr "" +"*sequence* 用於填充 (populate) 一個充滿值的新 ``ShareableList``。設定為 " +"``None`` 以透過其唯一的共享記憶體名稱來附加到已經存在的 ``ShareableList``。" #: ../../library/multiprocessing.shared_memory.rst:274 msgid "" @@ -234,6 +303,9 @@ msgid "" "``ShareableList``, specify its shared memory block's unique name while " "leaving ``sequence`` set to ``None``." msgstr "" +"如 :class:`SharedMemory` 的定義中所述,*name* 是被請求之共享記憶體的唯一名" +"稱。當附加到現有的 ``ShareableList`` 時,指定其共享記憶體區塊的唯一名稱,同時" +"將 ``sequence`` 設定為 ``None``。" #: ../../library/multiprocessing.shared_memory.rst:281 msgid "" @@ -243,6 +315,11 @@ msgid "" "rstrip(b'\\x00')`` behavior is considered a bug and may go away in the " "future. See :gh:`106939`." msgstr "" +":class:`bytes` 和 :class:`str` 值存在一個已知問題。如果它們以 ``\\x00`` nul " +"位元組或字元結尾,那麼當透過索引從 :class:`ShareableList` 中獲取它們時,這些" +"位元組或字元可能會被\\ *默默地剝離 (silently stripped)*。這種 ``." +"rstrip(b'\\x00')`` 行為被認為是一個錯誤,將來可能會消失。請參閱 :gh:" +"`106939`。" #: ../../library/multiprocessing.shared_memory.rst:287 msgid "" @@ -250,32 +327,37 @@ msgid "" "around it by always unconditionally appending an extra non-0 byte to the end " "of such values when storing and unconditionally removing it when fetching:" msgstr "" +"對於去除尾隨空值 (rstripping of trailing nulls) 會出問題的應用程式,變通解法 " +"(work around) 是始終無條件地在儲存時於此類值的末尾追加一個額外非 0 位元組,並" +"在獲取時也無條件地刪除它:" #: ../../library/multiprocessing.shared_memory.rst:310 msgid "Returns the number of occurrences of ``value``." -msgstr "" +msgstr "回傳 ``value`` 出現的次數。" #: ../../library/multiprocessing.shared_memory.rst:314 msgid "" "Returns first index position of ``value``. Raises :exc:`ValueError` if " "``value`` is not present." msgstr "" +"回傳 ``value`` 的第一個索引位置。如果 ``value`` 不存在,則引發 :exc:" +"`ValueError`。" #: ../../library/multiprocessing.shared_memory.rst:319 msgid "" "Read-only attribute containing the :mod:`struct` packing format used by all " "currently stored values." -msgstr "" +msgstr "唯讀屬性,包含所有目前有儲存的值所使用的 :mod:`struct` 打包格式。" #: ../../library/multiprocessing.shared_memory.rst:324 msgid "The :class:`SharedMemory` instance where the values are stored." -msgstr "" +msgstr "儲存值的 :class:`SharedMemory` 實例。" #: ../../library/multiprocessing.shared_memory.rst:327 msgid "" "The following example demonstrates basic use of a :class:`ShareableList` " "instance:" -msgstr "" +msgstr "以下範例示範了 :class:`ShareableList` 實例的基本用法:" #: ../../library/multiprocessing.shared_memory.rst:360 msgid "" @@ -283,6 +365,8 @@ msgid "" "same :class:`ShareableList` by supplying the name of the shared memory block " "behind it:" msgstr "" +"以下範例描述了一個、兩個或多個行程如何透過提供後面的共享記憶體區塊名稱來存取" +"同一個 :class:`ShareableList`:" #: ../../library/multiprocessing.shared_memory.rst:375 msgid "" @@ -292,6 +376,10 @@ msgid "" "deserialized object has the same unique name and is just attached to an " "existing object with the same name (if the object is still alive):" msgstr "" +"以下範例示範了如果需要,可以對 ``ShareableList``\\ (和底層 " +"``SharedMemory``\\ )物件進行 pickle 和 unpickle。請注意,它仍然是相同的共享" +"物件。發生這種情況是因為反序列化的物件具有相同的唯一名稱,並且只是附加到具有" +"相同名稱的現有物件(如果該物件仍然存在):" #: ../../library/multiprocessing.shared_memory.rst:11 msgid "Shared Memory" From c56ab097ddcb73bb6ef7e7993cc8d97fdd7351ce Mon Sep 17 00:00:00 2001 From: "Wei-Hsiang (Matt) Wang" Date: Mon, 11 Dec 2023 22:51:17 +0800 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: cschan <45995789+cschan1828@users.noreply.github.com> --- library/multiprocessing.shared_memory.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/multiprocessing.shared_memory.po b/library/multiprocessing.shared_memory.po index dd63ea6ffc..16cb871768 100644 --- a/library/multiprocessing.shared_memory.po +++ b/library/multiprocessing.shared_memory.po @@ -60,9 +60,9 @@ msgid "" msgstr "" "在此模組中,共享記憶體是指「System V 風格」的共享記憶體區塊(儘管不一定如此明" "確實作),而不是指「分散式共享記憶體 (distributed shared memory)」。這種型別" -"的共享記憶體允許不同的行程潛在地讀取和寫入易失性記憶體 (volatile memory) 的公" +"的共享記憶體允許不同的行程潛在地讀取和寫入揮發性記憶體 (volatile memory) 的公" "開(或共享)區域。通常行程只能存取自己的行程記憶體空間,但共享記憶體允許在行" -"程之間共享資料,從而避免了在包含該資料的行程之間發送訊息的需求。與透過硬碟或 " +"程之間共享資料,從而避免需要跨行程傳遞資料的情境。與透過硬碟或 " "socket 或其他需要序列化/還原序列化 (serialization/deserialization) 和複製資料" "的通訊方式以共享資料相比,直接透過記憶體共享資料可以提供顯著的性能優勢。" @@ -167,7 +167,7 @@ msgstr "對共享記憶體區塊大小(以位元組為單位)的唯讀存取 msgid "" "The following example demonstrates low-level use of :class:`SharedMemory` " "instances::" -msgstr "以下範例示範了 :class:`SharedMemory` 實例的低階使用方式:: :" +msgstr "以下範例示範了 :class:`SharedMemory` 實例的低階使用方式: ::" #: ../../library/multiprocessing.shared_memory.rst:127 msgid "" From c837a5935cfe473fdf3e4169d1923f375df13163 Mon Sep 17 00:00:00 2001 From: "Wei-Hsiang (Matt) Wang" Date: Wed, 13 Dec 2023 13:53:59 +0800 Subject: [PATCH 3/3] Update library/multiprocessing.shared_memory.po Co-authored-by: cschan <45995789+cschan1828@users.noreply.github.com> --- library/multiprocessing.shared_memory.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/multiprocessing.shared_memory.po b/library/multiprocessing.shared_memory.po index 16cb871768..dc53aa765d 100644 --- a/library/multiprocessing.shared_memory.po +++ b/library/multiprocessing.shared_memory.po @@ -328,7 +328,7 @@ msgid "" "of such values when storing and unconditionally removing it when fetching:" msgstr "" "對於去除尾隨空值 (rstripping of trailing nulls) 會出問題的應用程式,變通解法 " -"(work around) 是始終無條件地在儲存時於此類值的末尾追加一個額外非 0 位元組,並" +"(workaround) 是始終無條件地在儲存時於此類值的末尾追加一個額外非 0 位元組,並" "在獲取時也無條件地刪除它:" #: ../../library/multiprocessing.shared_memory.rst:310