7
7
msgstr ""
8
8
"Project-Id-Version :Python 3.12\n "
9
9
"Report-Msgid-Bugs-To :\n "
10
- "POT-Creation-Date :2024-04-18 00:04 +0000\n "
11
- "PO-Revision-Date :2018 -05-23 16:15+0000 \n "
10
+ "POT-Creation-Date :2023-10-11 17:13 +0000\n "
11
+ "PO-Revision-Date :2024 -05-08 22:24+0800 \n "
12
12
"Last-Translator :Adrian Liaw <adrianliaw2000@gmail.com>\n "
13
13
"Language-Team :Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
14
14
"tw)\n "
@@ -17,10 +17,11 @@ msgstr ""
17
17
"Content-Type :text/plain; charset=UTF-8\n "
18
18
"Content-Transfer-Encoding :8bit\n "
19
19
"Plural-Forms :nplurals=1; plural=0;\n "
20
+ "X-Generator :Poedit 3.4.1\n "
20
21
21
22
#: ../../library/weakref.rst:4
22
23
msgid ":mod:`weakref` --- Weak references"
23
- msgstr ""
24
+ msgstr ":mod:`weakref` --- 弱參照 "
24
25
25
26
#: ../../library/weakref.rst:14
26
27
msgid "**Source code:** :source:`Lib/weakref.py`"
@@ -30,13 +31,14 @@ msgstr "**原始碼:**\\ :source:`Lib/weakref.py`"
30
31
msgid ""
31
32
"The :mod:`weakref` module allows the Python programmer to create :dfn:`weak "
32
33
"references` to objects."
33
- msgstr ""
34
+ msgstr ":mod:`weakref` 模組允許 Python 程式設計師建立對物件的 :dfn:`弱參照`。 "
34
35
35
36
#: ../../library/weakref.rst:24
36
37
msgid ""
37
38
"In the following, the term :dfn:`referent` means the object which is "
38
39
"referred to by a weak reference."
39
40
msgstr ""
41
+ "在以下文章中,術語 :dfn:`參照目標 (referent)` 表示被弱參照所參考的物件。"
40
42
41
43
#: ../../library/weakref.rst:27
42
44
msgid ""
@@ -47,13 +49,19 @@ msgid ""
47
49
"weak reference may return the object even if there are no strong references "
48
50
"to it."
49
51
msgstr ""
52
+ "對物件的弱參照不足以使物件保持存在:當對參照目標的唯一剩下的參照是弱參照時,:"
53
+ "term:`garbage collection` 可以自由地銷毀參照目標並將其記憶體重新用於其他用"
54
+ "途。然而,在物件被確實銷毀之前,即使沒有對該物件的強參照 (strong reference),"
55
+ "弱參照也可能會回傳該物件。"
50
56
51
57
#: ../../library/weakref.rst:33
52
58
msgid ""
53
59
"A primary use for weak references is to implement caches or mappings holding "
54
60
"large objects, where it's desired that a large object not be kept alive "
55
61
"solely because it appears in a cache or mapping."
56
62
msgstr ""
63
+ "弱參照的主要用途是實作保存大型物件的快取或對映,其不希望大型物件僅僅因為它出"
64
+ "現在快取或對映中而保持存在。"
57
65
58
66
#: ../../library/weakref.rst:37
59
67
msgid ""
@@ -70,6 +78,15 @@ msgid ""
70
78
"collection can reclaim the object, and its corresponding entries in weak "
71
79
"mappings are simply deleted."
72
80
msgstr ""
81
+ "例如,如果你有許多大型的二進位影像物件,你可能會想要為每個物件關聯 "
82
+ "(associate) 一個名稱。如果你使用 Python 字典將名稱對映到影像,或將影像對映到"
83
+ "名稱,則影像物件將保持存活,僅因為它們在字典中作為值 (value) 或鍵 (key) 出"
84
+ "現。:mod:`weakref` 模組提供的 :class:`WeakKeyDictionary` 和 :class:"
85
+ "`WeakValueDictionary` 類別是另一種選擇,它們使用弱參照來建構對映,這些對映不"
86
+ "會僅因為物件出現在對映物件中而使物件保持存活。例如,如果一個影像物件是 :"
87
+ "class:`WeakValueDictionary` 中的一個值,那麼當對該影像物件最後的參照是弱對映 "
88
+ "(weak mapping) 所持有的弱參照時,垃圾回收 (garbage collection) 可以回收該物"
89
+ "件,且其對應的條目在弱對映中會被完全地刪除。"
73
90
74
91
#: ../../library/weakref.rst:50
75
92
msgid ""
@@ -80,6 +97,10 @@ msgid ""
80
97
"class:`set` interface, but keeps weak references to its elements, just like "
81
98
"a :class:`WeakKeyDictionary` does."
82
99
msgstr ""
100
+ ":class:`WeakKeyDictionary` 和 :class:`WeakValueDictionary` 在其實作中使用弱參"
101
+ "照,在弱參照上設定回呼函式,此弱參照在垃圾回收取回鍵或值時通知弱字典。:class:"
102
+ "`WeakSet` 實作了 :class:`set` 介面,但保留對其元素的弱參照,就像 :class:"
103
+ "`WeakKeyDictionary` 一樣。"
83
104
84
105
#: ../../library/weakref.rst:57
85
106
msgid ""
@@ -89,6 +110,9 @@ msgid ""
89
110
"the module automatically ensures that the finalizer remains alive until the "
90
111
"object is collected."
91
112
msgstr ""
113
+ ":class:`finalize` 提供了一種直接的方法來註冊在物件被垃圾回收時呼叫的清理函"
114
+ "式。這比在原始弱參照上設定回呼函式更容易使用,因為模組在物件被收集前會自動確"
115
+ "保終結函式 (finalizer) 保持存活。"
92
116
93
117
#: ../../library/weakref.rst:63
94
118
msgid ""
@@ -97,6 +121,9 @@ msgid ""
97
121
"your own weak references directly. The low-level machinery is exposed by "
98
122
"the :mod:`weakref` module for the benefit of advanced uses."
99
123
msgstr ""
124
+ "大多數程式應該發現使用這些弱容器種類之一或 :class:`finalize` 就足夠了—通常不"
125
+ "需要直接建立自己的弱參照。低層級的機制由 :mod:`weakref` 模組公開,以利於進階"
126
+ "用途。"
100
127
101
128
#: ../../library/weakref.rst:68
102
129
msgid ""
@@ -106,28 +133,38 @@ msgid ""
106
133
"object>`, :term:`generators <generator>`, type objects, sockets, arrays, "
107
134
"deques, regular expression pattern objects, and code objects."
108
135
msgstr ""
136
+ "並非所有物件都可以被弱參照。支援弱參照的物件包括類別實例、用 Python (但不是"
137
+ "C)編寫的函式、實例方法、集合、凍結集合 (frozenset)、一些\\ :term:`檔案物件 "
138
+ "<file object>`、:term:`產生器 <generator>`、類型物件、socket、陣列、雙向佇"
139
+ "列、正規表示式模式物件和程式碼物件。"
109
140
110
141
#: ../../library/weakref.rst:74
111
142
msgid "Added support for thread.lock, threading.Lock, and code objects."
112
- msgstr ""
143
+ msgstr "新增了對 thread.lock、threading.Lock 和程式碼物件的支援。 "
113
144
114
145
#: ../../library/weakref.rst:77
115
146
msgid ""
116
147
"Several built-in types such as :class:`list` and :class:`dict` do not "
117
148
"directly support weak references but can add support through subclassing::"
118
149
msgstr ""
150
+ "一些內建型別,例如 :class:`list` 和 :class:`dict` 不直接支援弱參照,但可以透"
151
+ "過子類別化來支援: ::"
119
152
120
153
#: ../../library/weakref.rst:87
121
154
msgid ""
122
155
"Other built-in types such as :class:`tuple` and :class:`int` do not support "
123
156
"weak references even when subclassed."
124
157
msgstr ""
158
+ "其他內建型別,例如 :class:`tuple` 和 :class:`int` 即使在子類別化時也不支援弱"
159
+ "參照。"
125
160
126
161
#: ../../library/weakref.rst:90
127
162
msgid ""
128
163
"Extension types can easily be made to support weak references; see :ref:"
129
164
"`weakref-support`."
130
165
msgstr ""
166
+ "擴充型別 (extension type) 可以輕易地支援弱參照;請參閱 :ref:`weakref-"
167
+ "support`。"
131
168
132
169
#: ../../library/weakref.rst:93
133
170
msgid ""
@@ -136,6 +173,9 @@ msgid ""
136
173
"of strings in the ``__slots__`` declaration. See :ref:`__slots__ "
137
174
"documentation <slots>` for details."
138
175
msgstr ""
176
+ "當為給定的型別定義 ``__slots__`` 時,弱參照支援將被停用,除非 "
177
+ "``'__weakref__'`` 字串也存在於 ``__slots__`` 宣告的字串序列中。詳情請參閱 :"
178
+ "ref:`__slots__ 文件 <slots>`。"
139
179
140
180
#: ../../library/weakref.rst:100
141
181
msgid ""
@@ -148,20 +188,29 @@ msgid ""
148
188
"passed as the only parameter to the callback; the referent will no longer be "
149
189
"available."
150
190
msgstr ""
191
+ "傳回對 *object* 的弱參照。如果參照目標仍存活,則可以透過呼叫參照物件來取回原"
192
+ "始物件;如果參照目標已不存活,呼叫參照物件將導致 :const:`None` 被回傳。如果 "
193
+ "*callback* 被提供而非 :const:`None`,且回傳的弱參照物件仍存活,那麼當物件即將"
194
+ "被終結 (finalize) 時,回呼將被呼叫;弱參照物件將作為唯一的參數傳遞給回呼;參"
195
+ "照物件將不再可用。"
151
196
152
197
#: ../../library/weakref.rst:108
153
198
msgid ""
154
199
"It is allowable for many weak references to be constructed for the same "
155
200
"object. Callbacks registered for each weak reference will be called from the "
156
201
"most recently registered callback to the oldest registered callback."
157
202
msgstr ""
203
+ "為同一個物件建構多個弱參照是可行的。為每個弱參照註冊的回呼將按照最新到最舊註"
204
+ "冊的回呼順序來被呼叫。"
158
205
159
206
#: ../../library/weakref.rst:112
160
207
msgid ""
161
208
"Exceptions raised by the callback will be noted on the standard error "
162
209
"output, but cannot be propagated; they are handled in exactly the same way "
163
210
"as exceptions raised from an object's :meth:`~object.__del__` method."
164
211
msgstr ""
212
+ "回呼引發的例外將在標準錯誤輸出中被註明,但無法被傳播;它們的處理方式與物件"
213
+ "的 :meth:`~object.__del__` 方法引發的例外完全相同。"
165
214
166
215
#: ../../library/weakref.rst:116
167
216
msgid ""
@@ -170,6 +219,9 @@ msgid ""
170
219
"`hash` is called the first time only after the *object* was deleted, the "
171
220
"call will raise :exc:`TypeError`."
172
221
msgstr ""
222
+ "如果 *object* 是\\ :term:`可雜湊的 <hashable>`,那麼弱參照就是可雜湊的。即使"
223
+ "在 *object* 被刪除後,它們仍將保留其雜湊值。如果僅在 *object* 刪除後才第一次"
224
+ "呼叫 :func:`hash`,則該呼叫將引發 :exc:`TypeError`。"
173
225
174
226
#: ../../library/weakref.rst:121
175
227
msgid ""
@@ -179,17 +231,22 @@ msgid ""
179
231
"referent has been deleted, the references are equal only if the reference "
180
232
"objects are the same object."
181
233
msgstr ""
234
+ "弱參照支援相等性的測試,但不支援排序。如果參照目標仍存活,則兩個參照與其參照"
235
+ "目標具有相同的相等關係(無論 *callback* 如何)。如果任一參照目標已被刪除,則"
236
+ "僅當參照物件是同一物件時,參照才相等。"
182
237
183
238
#: ../../library/weakref.rst:126
184
239
msgid "This is a subclassable type rather than a factory function."
185
- msgstr ""
240
+ msgstr "這是一個可子類別化的型別,而不是一個工廠函式。 "
186
241
187
242
#: ../../library/weakref.rst:130
188
243
msgid ""
189
244
"This read-only attribute returns the callback currently associated to the "
190
245
"weakref. If there is no callback or if the referent of the weakref is no "
191
246
"longer alive then this attribute will have value ``None``."
192
247
msgstr ""
248
+ "此唯讀屬性回傳目前與弱參照關聯的回呼。如果沒有回呼或弱參照的參照目標已不存"
249
+ "活,那麼該屬性的值為 ``None``。"
193
250
194
251
#: ../../library/weakref.rst:134
195
252
msgid "Added the :attr:`__callback__` attribute."
@@ -207,29 +264,35 @@ msgid ""
207
264
"keys. *callback* is the same as the parameter of the same name to the :func:"
208
265
"`ref` function."
209
266
msgstr ""
267
+ "傳回一個使用弱參照的 *object* 的代理 (proxy)。這支援在大多數情境中使用代理,"
268
+ "而不需要對弱參照物件明確地取消參照。回傳的物件將具有 ``ProxyType`` 或 "
269
+ "``CallableProxyType`` 型別,具體取決於 *object* 是否為可呼叫物件。無論參照目"
270
+ "標如何,代理物件都不是 :term:`hashable`;這避免了與其基本可變物件本質相關的許"
271
+ "多問題,並阻止它們作為字典的鍵被使用。*callback* 與 :func:`ref` 函式的同名參"
272
+ "數是相同的。"
210
273
211
274
#: ../../library/weakref.rst:149
212
275
msgid ""
213
276
"Accessing an attribute of the proxy object after the referent is garbage "
214
277
"collected raises :exc:`ReferenceError`."
215
- msgstr ""
278
+ msgstr "在參照目標被垃圾回收後存取代理物件的屬性會引發 :exc:`ReferenceError`。 "
216
279
217
280
#: ../../library/weakref.rst:152
218
281
msgid ""
219
282
"Extended the operator support on proxy objects to include the matrix "
220
283
"multiplication operators ``@`` and ``@=``."
221
- msgstr ""
284
+ msgstr "提供對代理物件的運算子支援,以包括矩陣乘法運算子 ``@`` 和 ``@=``。 "
222
285
223
286
#: ../../library/weakref.rst:159
224
287
msgid ""
225
288
"Return the number of weak references and proxies which refer to *object*."
226
- msgstr ""
289
+ msgstr "回傳參照 *object* 的弱參照和代理的數量。 "
227
290
228
291
#: ../../library/weakref.rst:164
229
292
msgid ""
230
293
"Return a list of all weak reference and proxy objects which refer to "
231
294
"*object*."
232
- msgstr ""
295
+ msgstr "回傳參照 *object* 的所有弱參照和代理物件的一個串列。 "
233
296
234
297
#: ../../library/weakref.rst:169
235
298
msgid ""
@@ -239,6 +302,9 @@ msgid ""
239
302
"of an application without adding attributes to those objects. This can be "
240
303
"especially useful with objects that override attribute accesses."
241
304
msgstr ""
305
+ "弱參照鍵的對映類別。當不再有對鍵的強參照時,字典中的條目將被丟棄。這可用於將"
306
+ "附加資料與應用程式其他部分擁有的物件相關聯,而無需向這些物件新增屬性。這對於"
307
+ "覆蓋屬性存取的物件特別有用。"
242
308
243
309
#: ../../library/weakref.rst:175
244
310
msgid ""
@@ -247,10 +313,13 @@ msgid ""
247
313
"not replace the existing key. Due to this, when the reference to the "
248
314
"original key is deleted, it also deletes the entry in the dictionary::"
249
315
msgstr ""
316
+ "請注意,當將與現有鍵具有相同值的鍵(但識別性不相等)插入字典時,它會替換該"
317
+ "值,但不會替換現有鍵。因此,當刪除對原始鍵的參照時,它也會刪除字典中的條"
318
+ "目: ::"
250
319
251
320
#: ../../library/weakref.rst:188
252
321
msgid "A workaround would be to remove the key prior to reassignment::"
253
- msgstr ""
322
+ msgstr "一個變通的解法是在重新賦值 (reassignment) 之前刪除鍵: :: "
254
323
255
324
#: ../../library/weakref.rst:199
256
325
msgid "Added support for ``|`` and ``|=`` operators, specified in :pep:`584`."
@@ -265,37 +334,44 @@ msgid ""
265
334
"references that will cause the garbage collector to keep the keys around "
266
335
"longer than needed."
267
336
msgstr ""
337
+ ":class:`WeakKeyDictionary` 物件有一個直接公開內部參照的附加方法。參照在被使用"
338
+ "時不保證是\" 存活的\" ,因此在使用之前需要檢查呼叫參照的結果。這可以用來防止建"
339
+ "立會導致垃圾回收器保留鍵的時間超過其所需時間的參照。"
268
340
269
341
#: ../../library/weakref.rst:212
270
342
msgid "Return an iterable of the weak references to the keys."
271
- msgstr ""
343
+ msgstr "傳回對鍵的弱參照的可疊代物件。 "
272
344
273
345
#: ../../library/weakref.rst:217
274
346
msgid ""
275
347
"Mapping class that references values weakly. Entries in the dictionary will "
276
348
"be discarded when no strong reference to the value exists any more."
277
- msgstr ""
349
+ msgstr "弱參照值的對映類別。當不再存在對值的強參照時,字典中的條目將被丟棄。 "
278
350
279
351
#: ../../library/weakref.rst:220
280
352
msgid ""
281
353
"Added support for ``|`` and ``|=`` operators, as specified in :pep:`584`."
282
- msgstr ""
354
+ msgstr "新增對 ``|`` 和 ``|=`` 運算子的支持,如 :pep:`584` 中所說明。 "
283
355
284
356
#: ../../library/weakref.rst:223
285
357
msgid ""
286
358
":class:`WeakValueDictionary` objects have an additional method that has the "
287
359
"same issues as the :meth:`WeakKeyDictionary.keyrefs` method."
288
360
msgstr ""
361
+ ":class:`WeakValueDictionary` 物件有一個附加方法,它與 :meth:"
362
+ "`WeakKeyDictionary.keyrefs` 方法有相同的問題。"
289
363
290
364
#: ../../library/weakref.rst:229
291
365
msgid "Return an iterable of the weak references to the values."
292
- msgstr ""
366
+ msgstr "傳回對值的弱參照的可疊代物件。 "
293
367
294
368
#: ../../library/weakref.rst:234
295
369
msgid ""
296
370
"Set class that keeps weak references to its elements. An element will be "
297
371
"discarded when no strong reference to it exists any more."
298
372
msgstr ""
373
+ "保留對其元素的弱參照的集合類別。當不再存在對某個元素的強參照時,該元素將被丟"
374
+ "棄。"
299
375
300
376
#: ../../library/weakref.rst:240
301
377
msgid ""
@@ -305,12 +381,16 @@ msgid ""
305
381
"hold of it. :class:`WeakMethod` has special code to recreate the bound "
306
382
"method until either the object or the original function dies::"
307
383
msgstr ""
384
+ "一個特製的 :class:`ref` 子類別,其模擬對繫結方法 (bound method) (即在類別上"
385
+ "定義並在實例上查找的方法)的弱參照。由於繫結方法是短暫存在的,因此標準弱參照"
386
+ "無法保留它。:class:`WeakMethod` 有特殊的程式碼來重新建立繫結方法,直到物件或"
387
+ "原始函式死亡: ::"
308
388
309
389
#: ../../library/weakref.rst:264
310
390
msgid ""
311
391
"*callback* is the same as the parameter of the same name to the :func:`ref` "
312
392
"function."
313
- msgstr ""
393
+ msgstr "*callback* 與 :func:`ref` 函式的同名參數是相同的。 "
314
394
315
395
#: ../../library/weakref.rst:270
316
396
msgid ""