77msgstr ""
88"Project-Id-Version : Python 3.12\n "
99"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 "
1212"Last-Translator : Adrian Liaw <adrianliaw2000@gmail.com>\n "
1313"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
1414"tw)\n "
@@ -17,10 +17,11 @@ msgstr ""
1717"Content-Type : text/plain; charset=UTF-8\n "
1818"Content-Transfer-Encoding : 8bit\n "
1919"Plural-Forms : nplurals=1; plural=0;\n "
20+ "X-Generator : Poedit 3.4.1\n "
2021
2122#: ../../library/weakref.rst:4
2223msgid ":mod:`weakref` --- Weak references"
23- msgstr ""
24+ msgstr ":mod:`weakref` --- 弱參照 "
2425
2526#: ../../library/weakref.rst:14
2627msgid "**Source code:** :source:`Lib/weakref.py`"
@@ -30,13 +31,14 @@ msgstr "**原始碼:**\\ :source:`Lib/weakref.py`"
3031msgid ""
3132"The :mod:`weakref` module allows the Python programmer to create :dfn:`weak "
3233"references` to objects."
33- msgstr ""
34+ msgstr ":mod:`weakref` 模組允許 Python 程式設計師建立對物件的 :dfn:`弱參照`。 "
3435
3536#: ../../library/weakref.rst:24
3637msgid ""
3738"In the following, the term :dfn:`referent` means the object which is "
3839"referred to by a weak reference."
3940msgstr ""
41+ "在以下文章中,術語 :dfn:`參照目標 (referent)` 表示被弱參照所參考的物件。"
4042
4143#: ../../library/weakref.rst:27
4244msgid ""
@@ -47,13 +49,19 @@ msgid ""
4749"weak reference may return the object even if there are no strong references "
4850"to it."
4951msgstr ""
52+ "對物件的弱參照不足以使物件保持存在:當對參照目標的唯一剩下的參照是弱參照時,:"
53+ "term:`garbage collection` 可以自由地銷毀參照目標並將其記憶體重新用於其他用"
54+ "途。然而,在物件被確實銷毀之前,即使沒有對該物件的強參照 (strong reference),"
55+ "弱參照也可能會回傳該物件。"
5056
5157#: ../../library/weakref.rst:33
5258msgid ""
5359"A primary use for weak references is to implement caches or mappings holding "
5460"large objects, where it's desired that a large object not be kept alive "
5561"solely because it appears in a cache or mapping."
5662msgstr ""
63+ "弱參照的主要用途是實作保存大型物件的快取或對映,其不希望大型物件僅僅因為它出"
64+ "現在快取或對映中而保持存在。"
5765
5866#: ../../library/weakref.rst:37
5967msgid ""
@@ -70,6 +78,15 @@ msgid ""
7078"collection can reclaim the object, and its corresponding entries in weak "
7179"mappings are simply deleted."
7280msgstr ""
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+ "件,且其對應的條目在弱對映中會被完全地刪除。"
7390
7491#: ../../library/weakref.rst:50
7592msgid ""
@@ -80,6 +97,10 @@ msgid ""
8097"class:`set` interface, but keeps weak references to its elements, just like "
8198"a :class:`WeakKeyDictionary` does."
8299msgstr ""
100+ ":class:`WeakKeyDictionary` 和 :class:`WeakValueDictionary` 在其實作中使用弱參"
101+ "照,在弱參照上設定回呼函式,此弱參照在垃圾回收取回鍵或值時通知弱字典。:class:"
102+ "`WeakSet` 實作了 :class:`set` 介面,但保留對其元素的弱參照,就像 :class:"
103+ "`WeakKeyDictionary` 一樣。"
83104
84105#: ../../library/weakref.rst:57
85106msgid ""
@@ -89,6 +110,9 @@ msgid ""
89110"the module automatically ensures that the finalizer remains alive until the "
90111"object is collected."
91112msgstr ""
113+ ":class:`finalize` 提供了一種直接的方法來註冊在物件被垃圾回收時呼叫的清理函"
114+ "式。這比在原始弱參照上設定回呼函式更容易使用,因為模組在物件被收集前會自動確"
115+ "保終結函式 (finalizer) 保持存活。"
92116
93117#: ../../library/weakref.rst:63
94118msgid ""
@@ -97,6 +121,9 @@ msgid ""
97121"your own weak references directly. The low-level machinery is exposed by "
98122"the :mod:`weakref` module for the benefit of advanced uses."
99123msgstr ""
124+ "大多數程式應該發現使用這些弱容器種類之一或 :class:`finalize` 就足夠了—通常不"
125+ "需要直接建立自己的弱參照。低層級的機制由 :mod:`weakref` 模組公開,以利於進階"
126+ "用途。"
100127
101128#: ../../library/weakref.rst:68
102129msgid ""
@@ -106,28 +133,38 @@ msgid ""
106133"object>`, :term:`generators <generator>`, type objects, sockets, arrays, "
107134"deques, regular expression pattern objects, and code objects."
108135msgstr ""
136+ "並非所有物件都可以被弱參照。支援弱參照的物件包括類別實例、用 Python (但不是"
137+ "C)編寫的函式、實例方法、集合、凍結集合 (frozenset)、一些\\ :term:`檔案物件 "
138+ "<file object>`、:term:`產生器 <generator>`、類型物件、socket、陣列、雙向佇"
139+ "列、正規表示式模式物件和程式碼物件。"
109140
110141#: ../../library/weakref.rst:74
111142msgid "Added support for thread.lock, threading.Lock, and code objects."
112- msgstr ""
143+ msgstr "新增了對 thread.lock、threading.Lock 和程式碼物件的支援。 "
113144
114145#: ../../library/weakref.rst:77
115146msgid ""
116147"Several built-in types such as :class:`list` and :class:`dict` do not "
117148"directly support weak references but can add support through subclassing::"
118149msgstr ""
150+ "一些內建型別,例如 :class:`list` 和 :class:`dict` 不直接支援弱參照,但可以透"
151+ "過子類別化來支援: ::"
119152
120153#: ../../library/weakref.rst:87
121154msgid ""
122155"Other built-in types such as :class:`tuple` and :class:`int` do not support "
123156"weak references even when subclassed."
124157msgstr ""
158+ "其他內建型別,例如 :class:`tuple` 和 :class:`int` 即使在子類別化時也不支援弱"
159+ "參照。"
125160
126161#: ../../library/weakref.rst:90
127162msgid ""
128163"Extension types can easily be made to support weak references; see :ref:"
129164"`weakref-support`."
130165msgstr ""
166+ "擴充型別 (extension type) 可以輕易地支援弱參照;請參閱 :ref:`weakref-"
167+ "support`。"
131168
132169#: ../../library/weakref.rst:93
133170msgid ""
@@ -136,6 +173,9 @@ msgid ""
136173"of strings in the ``__slots__`` declaration. See :ref:`__slots__ "
137174"documentation <slots>` for details."
138175msgstr ""
176+ "當為給定的型別定義 ``__slots__`` 時,弱參照支援將被停用,除非 "
177+ "``'__weakref__'`` 字串也存在於 ``__slots__`` 宣告的字串序列中。詳情請參閱 :"
178+ "ref:`__slots__ 文件 <slots>`。"
139179
140180#: ../../library/weakref.rst:100
141181msgid ""
@@ -148,20 +188,29 @@ msgid ""
148188"passed as the only parameter to the callback; the referent will no longer be "
149189"available."
150190msgstr ""
191+ "傳回對 *object* 的弱參照。如果參照目標仍存活,則可以透過呼叫參照物件來取回原"
192+ "始物件;如果參照目標已不存活,呼叫參照物件將導致 :const:`None` 被回傳。如果 "
193+ "*callback* 被提供而非 :const:`None`,且回傳的弱參照物件仍存活,那麼當物件即將"
194+ "被終結 (finalize) 時,回呼將被呼叫;弱參照物件將作為唯一的參數傳遞給回呼;參"
195+ "照物件將不再可用。"
151196
152197#: ../../library/weakref.rst:108
153198msgid ""
154199"It is allowable for many weak references to be constructed for the same "
155200"object. Callbacks registered for each weak reference will be called from the "
156201"most recently registered callback to the oldest registered callback."
157202msgstr ""
203+ "為同一個物件建構多個弱參照是可行的。為每個弱參照註冊的回呼將按照最新到最舊註"
204+ "冊的回呼順序來被呼叫。"
158205
159206#: ../../library/weakref.rst:112
160207msgid ""
161208"Exceptions raised by the callback will be noted on the standard error "
162209"output, but cannot be propagated; they are handled in exactly the same way "
163210"as exceptions raised from an object's :meth:`~object.__del__` method."
164211msgstr ""
212+ "回呼引發的例外將在標準錯誤輸出中被註明,但無法被傳播;它們的處理方式與物件"
213+ "的 :meth:`~object.__del__` 方法引發的例外完全相同。"
165214
166215#: ../../library/weakref.rst:116
167216msgid ""
@@ -170,6 +219,9 @@ msgid ""
170219"`hash` is called the first time only after the *object* was deleted, the "
171220"call will raise :exc:`TypeError`."
172221msgstr ""
222+ "如果 *object* 是\\ :term:`可雜湊的 <hashable>`,那麼弱參照就是可雜湊的。即使"
223+ "在 *object* 被刪除後,它們仍將保留其雜湊值。如果僅在 *object* 刪除後才第一次"
224+ "呼叫 :func:`hash`,則該呼叫將引發 :exc:`TypeError`。"
173225
174226#: ../../library/weakref.rst:121
175227msgid ""
@@ -179,17 +231,22 @@ msgid ""
179231"referent has been deleted, the references are equal only if the reference "
180232"objects are the same object."
181233msgstr ""
234+ "弱參照支援相等性的測試,但不支援排序。如果參照目標仍存活,則兩個參照與其參照"
235+ "目標具有相同的相等關係(無論 *callback* 如何)。如果任一參照目標已被刪除,則"
236+ "僅當參照物件是同一物件時,參照才相等。"
182237
183238#: ../../library/weakref.rst:126
184239msgid "This is a subclassable type rather than a factory function."
185- msgstr ""
240+ msgstr "這是一個可子類別化的型別,而不是一個工廠函式。 "
186241
187242#: ../../library/weakref.rst:130
188243msgid ""
189244"This read-only attribute returns the callback currently associated to the "
190245"weakref. If there is no callback or if the referent of the weakref is no "
191246"longer alive then this attribute will have value ``None``."
192247msgstr ""
248+ "此唯讀屬性回傳目前與弱參照關聯的回呼。如果沒有回呼或弱參照的參照目標已不存"
249+ "活,那麼該屬性的值為 ``None``。"
193250
194251#: ../../library/weakref.rst:134
195252msgid "Added the :attr:`__callback__` attribute."
@@ -207,29 +264,35 @@ msgid ""
207264"keys. *callback* is the same as the parameter of the same name to the :func:"
208265"`ref` function."
209266msgstr ""
267+ "傳回一個使用弱參照的 *object* 的代理 (proxy)。這支援在大多數情境中使用代理,"
268+ "而不需要對弱參照物件明確地取消參照。回傳的物件將具有 ``ProxyType`` 或 "
269+ "``CallableProxyType`` 型別,具體取決於 *object* 是否為可呼叫物件。無論參照目"
270+ "標如何,代理物件都不是 :term:`hashable`;這避免了與其基本可變物件本質相關的許"
271+ "多問題,並阻止它們作為字典的鍵被使用。*callback* 與 :func:`ref` 函式的同名參"
272+ "數是相同的。"
210273
211274#: ../../library/weakref.rst:149
212275msgid ""
213276"Accessing an attribute of the proxy object after the referent is garbage "
214277"collected raises :exc:`ReferenceError`."
215- msgstr ""
278+ msgstr "在參照目標被垃圾回收後存取代理物件的屬性會引發 :exc:`ReferenceError`。 "
216279
217280#: ../../library/weakref.rst:152
218281msgid ""
219282"Extended the operator support on proxy objects to include the matrix "
220283"multiplication operators ``@`` and ``@=``."
221- msgstr ""
284+ msgstr "提供對代理物件的運算子支援,以包括矩陣乘法運算子 ``@`` 和 ``@=``。 "
222285
223286#: ../../library/weakref.rst:159
224287msgid ""
225288"Return the number of weak references and proxies which refer to *object*."
226- msgstr ""
289+ msgstr "回傳參照 *object* 的弱參照和代理的數量。 "
227290
228291#: ../../library/weakref.rst:164
229292msgid ""
230293"Return a list of all weak reference and proxy objects which refer to "
231294"*object*."
232- msgstr ""
295+ msgstr "回傳參照 *object* 的所有弱參照和代理物件的一個串列。 "
233296
234297#: ../../library/weakref.rst:169
235298msgid ""
@@ -239,6 +302,9 @@ msgid ""
239302"of an application without adding attributes to those objects. This can be "
240303"especially useful with objects that override attribute accesses."
241304msgstr ""
305+ "弱參照鍵的對映類別。當不再有對鍵的強參照時,字典中的條目將被丟棄。這可用於將"
306+ "附加資料與應用程式其他部分擁有的物件相關聯,而無需向這些物件新增屬性。這對於"
307+ "覆蓋屬性存取的物件特別有用。"
242308
243309#: ../../library/weakref.rst:175
244310msgid ""
@@ -247,10 +313,13 @@ msgid ""
247313"not replace the existing key. Due to this, when the reference to the "
248314"original key is deleted, it also deletes the entry in the dictionary::"
249315msgstr ""
316+ "請注意,當將與現有鍵具有相同值的鍵(但識別性不相等)插入字典時,它會替換該"
317+ "值,但不會替換現有鍵。因此,當刪除對原始鍵的參照時,它也會刪除字典中的條"
318+ "目: ::"
250319
251320#: ../../library/weakref.rst:188
252321msgid "A workaround would be to remove the key prior to reassignment::"
253- msgstr ""
322+ msgstr "一個變通的解法是在重新賦值 (reassignment) 之前刪除鍵: :: "
254323
255324#: ../../library/weakref.rst:199
256325msgid "Added support for ``|`` and ``|=`` operators, specified in :pep:`584`."
@@ -265,37 +334,44 @@ msgid ""
265334"references that will cause the garbage collector to keep the keys around "
266335"longer than needed."
267336msgstr ""
337+ ":class:`WeakKeyDictionary` 物件有一個直接公開內部參照的附加方法。參照在被使用"
338+ "時不保證是 \" 存活的\" ,因此在使用之前需要檢查呼叫參照的結果。這可以用來防止建"
339+ "立會導致垃圾回收器保留鍵的時間超過其所需時間的參照。"
268340
269341#: ../../library/weakref.rst:212
270342msgid "Return an iterable of the weak references to the keys."
271- msgstr ""
343+ msgstr "傳回對鍵的弱參照的可疊代物件。 "
272344
273345#: ../../library/weakref.rst:217
274346msgid ""
275347"Mapping class that references values weakly. Entries in the dictionary will "
276348"be discarded when no strong reference to the value exists any more."
277- msgstr ""
349+ msgstr "弱參照值的對映類別。當不再存在對值的強參照時,字典中的條目將被丟棄。 "
278350
279351#: ../../library/weakref.rst:220
280352msgid ""
281353"Added support for ``|`` and ``|=`` operators, as specified in :pep:`584`."
282- msgstr ""
354+ msgstr "新增對 ``|`` 和 ``|=`` 運算子的支持,如 :pep:`584` 中所說明。 "
283355
284356#: ../../library/weakref.rst:223
285357msgid ""
286358":class:`WeakValueDictionary` objects have an additional method that has the "
287359"same issues as the :meth:`WeakKeyDictionary.keyrefs` method."
288360msgstr ""
361+ ":class:`WeakValueDictionary` 物件有一個附加方法,它與 :meth:"
362+ "`WeakKeyDictionary.keyrefs` 方法有相同的問題。"
289363
290364#: ../../library/weakref.rst:229
291365msgid "Return an iterable of the weak references to the values."
292- msgstr ""
366+ msgstr "傳回對值的弱參照的可疊代物件。 "
293367
294368#: ../../library/weakref.rst:234
295369msgid ""
296370"Set class that keeps weak references to its elements. An element will be "
297371"discarded when no strong reference to it exists any more."
298372msgstr ""
373+ "保留對其元素的弱參照的集合類別。當不再存在對某個元素的強參照時,該元素將被丟"
374+ "棄。"
299375
300376#: ../../library/weakref.rst:240
301377msgid ""
@@ -305,12 +381,16 @@ msgid ""
305381"hold of it. :class:`WeakMethod` has special code to recreate the bound "
306382"method until either the object or the original function dies::"
307383msgstr ""
384+ "一個特製的 :class:`ref` 子類別,其模擬對繫結方法 (bound method) (即在類別上"
385+ "定義並在實例上查找的方法)的弱參照。由於繫結方法是短暫存在的,因此標準弱參照"
386+ "無法保留它。:class:`WeakMethod` 有特殊的程式碼來重新建立繫結方法,直到物件或"
387+ "原始函式死亡: ::"
308388
309389#: ../../library/weakref.rst:264
310390msgid ""
311391"*callback* is the same as the parameter of the same name to the :func:`ref` "
312392"function."
313- msgstr ""
393+ msgstr "*callback* 與 :func:`ref` 函式的同名參數是相同的。 "
314394
315395#: ../../library/weakref.rst:270
316396msgid ""
0 commit comments