1
- # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) 2001-2022, Python Software Foundation
1
+ # Copyright (C) 2001-2023, Python Software Foundation
3
2
# This file is distributed under the same license as the Python package.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
3
#
4
+ # Translators:
5
+ # Matt Wang <[email protected] >, 2023
6
6
msgid ""
7
7
msgstr ""
8
8
"Project-Id-Version : Python 3.12\n "
9
9
"Report-Msgid-Bugs-To : \n "
10
10
"POT-Creation-Date : 2023-07-26 00:03+0000\n "
11
- "PO-Revision-Date : YEAR-MO-DA HO:MI+ZONE \n "
12
- "Last-Translator : FULL NAME <EMAIL@ADDRESS >\n "
11
+ "PO-Revision-Date : 2023-12-11 00:03+0800 \n "
12
+ "
Last-Translator :
Matt Wang <[email protected] >\n"
13
13
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
14
14
"tw)\n "
15
15
"Language : zh_TW\n "
@@ -22,6 +22,7 @@ msgid ""
22
22
":mod:`multiprocessing.shared_memory` --- Shared memory for direct access "
23
23
"across processes"
24
24
msgstr ""
25
+ ":mod:`multiprocessing.shared_memory` --- 對於共享記憶體的跨行程直接存取"
25
26
26
27
#: ../../library/multiprocessing.shared_memory.rst:7
27
28
msgid "**Source code:** :source:`Lib/multiprocessing/shared_memory.py`"
@@ -37,6 +38,11 @@ msgid ""
37
38
"`SharedMemoryManager`, is also provided in the ``multiprocessing.managers`` "
38
39
"module."
39
40
msgstr ""
41
+ "該模組提供了一個 :class:`SharedMemory` 類別,用於分配和管理被多核心或對稱多處"
42
+ "理器 (symmetric multiprocessor, SMP) 機器上的一個或多個行程存取的共享記憶體。"
43
+ "為了協助共享記憶體的生命週期管理,特別是跨不同行程的管理,``multiprocessing."
44
+ "managers`` 模組中還提供了一個 :class:`~multiprocessing.managers.BaseManager` "
45
+ "子類別 :class:`SharedMemoryManager`。"
40
46
41
47
#: ../../library/multiprocessing.shared_memory.rst:26
42
48
msgid ""
@@ -52,6 +58,13 @@ msgid ""
52
58
"via disk or socket or other communications requiring the serialization/"
53
59
"deserialization and copying of data."
54
60
msgstr ""
61
+ "在此模組中,共享記憶體是指「System V 風格」的共享記憶體區塊(儘管不一定如此明"
62
+ "確實作),而不是指「分散式共享記憶體 (distributed shared memory)」。這種型別"
63
+ "的共享記憶體允許不同的行程潛在地讀取和寫入揮發性記憶體 (volatile memory) 的公"
64
+ "開(或共享)區域。通常行程只能存取自己的行程記憶體空間,但共享記憶體允許在行"
65
+ "程之間共享資料,從而避免需要跨行程傳遞資料的情境。與透過硬碟或 "
66
+ "socket 或其他需要序列化/還原序列化 (serialization/deserialization) 和複製資料"
67
+ "的通訊方式以共享資料相比,直接透過記憶體共享資料可以提供顯著的性能優勢。"
55
68
56
69
#: ../../library/multiprocessing.shared_memory.rst:41
57
70
msgid ""
@@ -61,6 +74,9 @@ msgid ""
61
74
"different process can attach to that same shared memory block using that "
62
75
"same name."
63
76
msgstr ""
77
+ "建立新的共享記憶體區塊或附加到現有的共享記憶體區塊。每個共享記憶體區塊都被分"
78
+ "配了一個唯一的名稱。透過這種方式,一個行程可以建立具有特定名稱的共享記憶體區"
79
+ "塊,而不同的行程可以使用該相同名稱附加到同一共享記憶體區塊。"
64
80
65
81
#: ../../library/multiprocessing.shared_memory.rst:47
66
82
msgid ""
@@ -71,19 +87,27 @@ msgid ""
71
87
"block is no longer needed by any process, the :meth:`unlink()` method should "
72
88
"be called to ensure proper cleanup."
73
89
msgstr ""
90
+ "作為跨行程共享資料的資源,共享記憶體區塊的壽命可能比建立它們的原始行程還要"
91
+ "長。當一個行程不再需要存取但其他行程可能仍需要的共享記憶體區塊時,應該呼叫 :"
92
+ "meth:`close()` 方法。當任何行程不再需要共享記憶體區塊時,應呼叫 :meth:"
93
+ "`unlink()` 方法以確保正確清理。"
74
94
75
95
#: ../../library/multiprocessing.shared_memory.rst:54
76
96
msgid ""
77
97
"*name* is the unique name for the requested shared memory, specified as a "
78
98
"string. When creating a new shared memory block, if ``None`` (the default) "
79
99
"is supplied for the name, a novel name will be generated."
80
100
msgstr ""
101
+ "*name* 是所請求的共享記憶體的唯一名稱,指定為字串。建立新的共享記憶體區塊時,"
102
+ "如果名稱提供為 ``None``\\ (預設值),則會生成一個新的名稱。"
81
103
82
104
#: ../../library/multiprocessing.shared_memory.rst:58
83
105
msgid ""
84
106
"*create* controls whether a new shared memory block is created (``True``) or "
85
107
"an existing shared memory block is attached (``False``)."
86
108
msgstr ""
109
+ "*create* 控制是否建立新的共享記憶體區塊 (``True``) 或附加現有的共享記憶體區"
110
+ "塊 (``False``)。"
87
111
88
112
#: ../../library/multiprocessing.shared_memory.rst:61
89
113
msgid ""
@@ -93,6 +117,10 @@ msgid ""
93
117
"memory block may be larger or equal to the size requested. When attaching "
94
118
"to an existing shared memory block, the ``size`` parameter is ignored."
95
119
msgstr ""
120
+ "*size* 指定了建立新共享記憶體區塊時請求的位元組數。由於某些平台會根據該平台的"
121
+ "記憶體頁 (memory page) 大小來選擇分配記憶體區塊,因此共享記憶體區塊的確切大小"
122
+ "可能大於或等於請求的大小。當附加到現有共享記憶體區塊時,``size`` 參數將被忽"
123
+ "略。"
96
124
97
125
#: ../../library/multiprocessing.shared_memory.rst:69
98
126
msgid ""
@@ -101,6 +129,9 @@ msgid ""
101
129
"instance is no longer needed. Note that calling ``close()`` does not cause "
102
130
"the shared memory block itself to be destroyed."
103
131
msgstr ""
132
+ "關閉從此實例對共享記憶體的存取。為了確保正確清理資源,一旦實例不再被需要,所"
133
+ "有實例都應該呼叫 ``close()``。請注意,呼叫 ``close()`` 不會使得共享記憶體區塊"
134
+ "本身被銷毀。"
104
135
105
136
#: ../../library/multiprocessing.shared_memory.rst:77
106
137
msgid ""
@@ -114,37 +145,46 @@ msgid ""
114
145
"relinquishing its hold on a shared memory block may call ``unlink()`` and :"
115
146
"meth:`close()` in either order."
116
147
msgstr ""
148
+ "請求銷毀底層共享記憶體區塊。為了確保正確清理資源,應該在需要共享記憶體區塊的"
149
+ "所有行程中呼叫一次(且僅一次)\\ ``unlink()``。請求銷毀後,共享記憶體區塊可能"
150
+ "會也可能不會立即銷毀,此行為可能因平台而異。呼叫 ``unlink()`` 後嘗試存取共享"
151
+ "記憶體區塊內的資料可能會導致記憶體存取錯誤。注意:最後一個放棄持有某共享記憶"
152
+ "體區塊的行程可以按任意順序呼叫 ``unlink()`` 和 :meth:`close()`。"
117
153
118
154
#: ../../library/multiprocessing.shared_memory.rst:90
119
155
msgid "A memoryview of contents of the shared memory block."
120
- msgstr ""
156
+ msgstr "共享記憶體區塊內容的記憶體視圖 (memoryview)。 "
121
157
122
158
#: ../../library/multiprocessing.shared_memory.rst:94
123
159
msgid "Read-only access to the unique name of the shared memory block."
124
- msgstr ""
160
+ msgstr "對共享記憶體區塊之唯一名稱的唯讀存取。 "
125
161
126
162
#: ../../library/multiprocessing.shared_memory.rst:98
127
163
msgid "Read-only access to size in bytes of the shared memory block."
128
- msgstr ""
164
+ msgstr "對共享記憶體區塊大小(以位元組為單位)的唯讀存取。 "
129
165
130
166
#: ../../library/multiprocessing.shared_memory.rst:101
131
167
msgid ""
132
168
"The following example demonstrates low-level use of :class:`SharedMemory` "
133
169
"instances::"
134
- msgstr ""
170
+ msgstr "以下範例示範了 :class:`SharedMemory` 實例的低階使用方式: :: "
135
171
136
172
#: ../../library/multiprocessing.shared_memory.rst:127
137
173
msgid ""
138
174
"The following example demonstrates a practical use of the :class:"
139
175
"`SharedMemory` class with `NumPy arrays <https://numpy.org/>`_, accessing "
140
176
"the same ``numpy.ndarray`` from two distinct Python shells:"
141
177
msgstr ""
178
+ "以下範例示範了 :class:`SharedMemory` 類別與 `NumPy 陣列 <https://numpy.org/"
179
+ ">`_\\ 的實際用法:從兩個不同的 Python shell 存取相同的 ``numpy.ndarray``:"
142
180
143
181
#: ../../library/multiprocessing.shared_memory.rst:181
144
182
msgid ""
145
183
"A subclass of :class:`~multiprocessing.managers.BaseManager` which can be "
146
184
"used for the management of shared memory blocks across processes."
147
185
msgstr ""
186
+ ":class:`~multiprocessing.managers.BaseManager` 的子類別,可用於跨行程管理共享"
187
+ "記憶體區塊。"
148
188
149
189
#: ../../library/multiprocessing.shared_memory.rst:184
150
190
msgid ""
@@ -159,13 +199,22 @@ msgid ""
159
199
"instances through a ``SharedMemoryManager``, we avoid the need to manually "
160
200
"track and trigger the freeing of shared memory resources."
161
201
msgstr ""
202
+ "在 :class:`SharedMemoryManager` 實例上呼叫 :meth:`~multiprocessing.managers."
203
+ "BaseManager.start` 會啟動一個新行程。這個新行程的唯一目的是管理那些透過它建立"
204
+ "出的所有共享記憶體區塊的生命週期。要觸發釋放該行程管理的所有共享記憶體區塊,"
205
+ "請在實例上呼叫 :meth:`~multiprocessing.managers.BaseManager.shutdown()`,這會"
206
+ "觸發對該行程管理的所有 :class:`SharedMemory` 物件的 :meth:`SharedMemory."
207
+ "unlink()` 呼叫,然後再停止這個行程。透過 ``SharedMemoryManager`` 建立 "
208
+ "``SharedMemory`` 實例,我們無需手動追蹤和觸發共享記憶體資源的釋放。"
162
209
163
210
#: ../../library/multiprocessing.shared_memory.rst:196
164
211
msgid ""
165
212
"This class provides methods for creating and returning :class:`SharedMemory` "
166
213
"instances and for creating a list-like object (:class:`ShareableList`) "
167
214
"backed by shared memory."
168
215
msgstr ""
216
+ "此類別提供了用於建立和回傳 :class:`SharedMemory` 實例以及建立由共享記憶體支援"
217
+ "的類串列物件 (:class:`ShareableList`) 的方法。"
169
218
170
219
#: ../../library/multiprocessing.shared_memory.rst:200
171
220
msgid ""
@@ -174,24 +223,31 @@ msgid ""
174
223
"may be used to connect to an existing ``SharedMemoryManager`` service from "
175
224
"other processes."
176
225
msgstr ""
226
+ "請參閱 :class:`multiprocessing.managers.BaseManager` 了解繼承的 *address* 和 "
227
+ "*authkey* 可選輸入引數的描述以及如何使用它們從其他行程連接到現有的 "
228
+ "``SharedMemoryManager`` 服務。"
177
229
178
230
#: ../../library/multiprocessing.shared_memory.rst:207
179
231
msgid ""
180
232
"Create and return a new :class:`SharedMemory` object with the specified "
181
233
"``size`` in bytes."
182
234
msgstr ""
235
+ "建立並回傳一個新的 :class:`SharedMemory` 物件,該物件具有指定的 ``size``\\ "
236
+ "(以位元組為單位)。"
183
237
184
238
#: ../../library/multiprocessing.shared_memory.rst:212
185
239
msgid ""
186
240
"Create and return a new :class:`ShareableList` object, initialized by the "
187
241
"values from the input ``sequence``."
188
242
msgstr ""
243
+ "建立並回傳一個新的 :class:`ShareableList` 物件,該物件由輸入 ``sequence`` 中"
244
+ "的值初始化。"
189
245
190
246
#: ../../library/multiprocessing.shared_memory.rst:216
191
247
msgid ""
192
248
"The following example demonstrates the basic mechanisms of a :class:"
193
249
"`SharedMemoryManager`:"
194
- msgstr ""
250
+ msgstr "以下範例示範了 :class:`SharedMemoryManager` 的基本作用機制: "
195
251
196
252
#: ../../library/multiprocessing.shared_memory.rst:234
197
253
msgid ""
@@ -200,13 +256,18 @@ msgid ""
200
256
"to ensure that all shared memory blocks are released after they are no "
201
257
"longer needed:"
202
258
msgstr ""
259
+ "以下範例描述了一種可能更方便的模式,即透過 :keyword:`with` 陳述式使用 :class:"
260
+ "`SharedMemoryManager` 物件,以確保所有共享記憶體區塊不再被需要後都被釋放:"
203
261
204
262
#: ../../library/multiprocessing.shared_memory.rst:253
205
263
msgid ""
206
264
"When using a :class:`SharedMemoryManager` in a :keyword:`with` statement, "
207
265
"the shared memory blocks created using that manager are all released when "
208
266
"the :keyword:`with` statement's code block finishes execution."
209
267
msgstr ""
268
+ "在 :keyword:`with` 陳述式中使用 :class:`SharedMemoryManager` 時,當 :keyword:"
269
+ "`with` 陳述式的程式碼區塊執行完畢時,使用該管理器建立的共享記憶體區塊都會被釋"
270
+ "放。"
210
271
211
272
#: ../../library/multiprocessing.shared_memory.rst:260
212
273
msgid ""
@@ -219,13 +280,21 @@ msgid ""
219
280
"no append, insert, etc.) and do not support the dynamic creation of new :"
220
281
"class:`ShareableList` instances via slicing."
221
282
msgstr ""
283
+ "提供一個類似串列的可變物件,其中有被儲存的所有值都儲存在共享記憶體區塊中。這"
284
+ "限制了可存儲的值只能夠是內建資料型別 ``int``\\ (帶符號的 64 位元 (signed 64-"
285
+ "bit))、``float``、``bool``、``str``\\ (編碼為 utf-8 時個別小於 10M 位元"
286
+ "組)、``bytes``\\ (個別小於 10M 位元組)和 ``None``。它還與內建的 ``list`` "
287
+ "型別有顯著不同,因為這些串列不能更改其總長度(即不能追加 (append)、插入等),"
288
+ "並且不支援透過切片動態建立新的 :class:`ShareableList` 實例。"
222
289
223
290
#: ../../library/multiprocessing.shared_memory.rst:270
224
291
msgid ""
225
292
"*sequence* is used in populating a new ``ShareableList`` full of values. Set "
226
293
"to ``None`` to instead attach to an already existing ``ShareableList`` by "
227
294
"its unique shared memory name."
228
295
msgstr ""
296
+ "*sequence* 用於填充 (populate) 一個充滿值的新 ``ShareableList``。設定為 "
297
+ "``None`` 以透過其唯一的共享記憶體名稱來附加到已經存在的 ``ShareableList``。"
229
298
230
299
#: ../../library/multiprocessing.shared_memory.rst:274
231
300
msgid ""
@@ -234,6 +303,9 @@ msgid ""
234
303
"``ShareableList``, specify its shared memory block's unique name while "
235
304
"leaving ``sequence`` set to ``None``."
236
305
msgstr ""
306
+ "如 :class:`SharedMemory` 的定義中所述,*name* 是被請求之共享記憶體的唯一名"
307
+ "稱。當附加到現有的 ``ShareableList`` 時,指定其共享記憶體區塊的唯一名稱,同時"
308
+ "將 ``sequence`` 設定為 ``None``。"
237
309
238
310
#: ../../library/multiprocessing.shared_memory.rst:281
239
311
msgid ""
@@ -243,46 +315,58 @@ msgid ""
243
315
"rstrip(b'\\ x00')`` behavior is considered a bug and may go away in the "
244
316
"future. See :gh:`106939`."
245
317
msgstr ""
318
+ ":class:`bytes` 和 :class:`str` 值存在一個已知問題。如果它們以 ``\\ x00`` nul "
319
+ "位元組或字元結尾,那麼當透過索引從 :class:`ShareableList` 中獲取它們時,這些"
320
+ "位元組或字元可能會被\\ *默默地剝離 (silently stripped)*。這種 ``."
321
+ "rstrip(b'\\ x00')`` 行為被認為是一個錯誤,將來可能會消失。請參閱 :gh:"
322
+ "`106939`。"
246
323
247
324
#: ../../library/multiprocessing.shared_memory.rst:287
248
325
msgid ""
249
326
"For applications where rstripping of trailing nulls is a problem, work "
250
327
"around it by always unconditionally appending an extra non-0 byte to the end "
251
328
"of such values when storing and unconditionally removing it when fetching:"
252
329
msgstr ""
330
+ "對於去除尾隨空值 (rstripping of trailing nulls) 會出問題的應用程式,變通解法 "
331
+ "(workaround) 是始終無條件地在儲存時於此類值的末尾追加一個額外非 0 位元組,並"
332
+ "在獲取時也無條件地刪除它:"
253
333
254
334
#: ../../library/multiprocessing.shared_memory.rst:310
255
335
msgid "Returns the number of occurrences of ``value``."
256
- msgstr ""
336
+ msgstr "回傳 ``value`` 出現的次數。 "
257
337
258
338
#: ../../library/multiprocessing.shared_memory.rst:314
259
339
msgid ""
260
340
"Returns first index position of ``value``. Raises :exc:`ValueError` if "
261
341
"``value`` is not present."
262
342
msgstr ""
343
+ "回傳 ``value`` 的第一個索引位置。如果 ``value`` 不存在,則引發 :exc:"
344
+ "`ValueError`。"
263
345
264
346
#: ../../library/multiprocessing.shared_memory.rst:319
265
347
msgid ""
266
348
"Read-only attribute containing the :mod:`struct` packing format used by all "
267
349
"currently stored values."
268
- msgstr ""
350
+ msgstr "唯讀屬性,包含所有目前有儲存的值所使用的 :mod:`struct` 打包格式。 "
269
351
270
352
#: ../../library/multiprocessing.shared_memory.rst:324
271
353
msgid "The :class:`SharedMemory` instance where the values are stored."
272
- msgstr ""
354
+ msgstr "儲存值的 :class:`SharedMemory` 實例。 "
273
355
274
356
#: ../../library/multiprocessing.shared_memory.rst:327
275
357
msgid ""
276
358
"The following example demonstrates basic use of a :class:`ShareableList` "
277
359
"instance:"
278
- msgstr ""
360
+ msgstr "以下範例示範了 :class:`ShareableList` 實例的基本用法: "
279
361
280
362
#: ../../library/multiprocessing.shared_memory.rst:360
281
363
msgid ""
282
364
"The following example depicts how one, two, or many processes may access the "
283
365
"same :class:`ShareableList` by supplying the name of the shared memory block "
284
366
"behind it:"
285
367
msgstr ""
368
+ "以下範例描述了一個、兩個或多個行程如何透過提供後面的共享記憶體區塊名稱來存取"
369
+ "同一個 :class:`ShareableList`:"
286
370
287
371
#: ../../library/multiprocessing.shared_memory.rst:375
288
372
msgid ""
@@ -292,6 +376,10 @@ msgid ""
292
376
"deserialized object has the same unique name and is just attached to an "
293
377
"existing object with the same name (if the object is still alive):"
294
378
msgstr ""
379
+ "以下範例示範了如果需要,可以對 ``ShareableList``\\ (和底層 "
380
+ "``SharedMemory``\\ )物件進行 pickle 和 unpickle。請注意,它仍然是相同的共享"
381
+ "物件。發生這種情況是因為反序列化的物件具有相同的唯一名稱,並且只是附加到具有"
382
+ "相同名稱的現有物件(如果該物件仍然存在):"
295
383
296
384
#: ../../library/multiprocessing.shared_memory.rst:11
297
385
msgid "Shared Memory"
0 commit comments