@@ -8,7 +8,7 @@ msgstr ""
8
8
"Project-Id-Version : Python 3.12\n "
9
9
"Report-Msgid-Bugs-To : \n "
10
10
"POT-Creation-Date : 2023-10-11 17:13+0000\n "
11
- "PO-Revision-Date : 2024-05-08 22:24 +0800\n "
11
+ "PO-Revision-Date : 2024-05-22 20:58 +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,7 +17,7 @@ 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
+ "X-Generator : Poedit 3.4.4 \n "
21
21
22
22
#: ../../library/weakref.rst:4
23
23
msgid ":mod:`weakref` --- Weak references"
@@ -111,8 +111,8 @@ msgid ""
111
111
"object is collected."
112
112
msgstr ""
113
113
":class:`finalize` 提供了一種直接的方法來註冊在物件被垃圾回收時呼叫的清理函"
114
- "式。這比在原始弱參照上設定回呼函式更容易使用,因為模組在物件被收集前會自動確 "
115
- "保終結函式 (finalizer) 保持存活。"
114
+ "式。這比在原始弱參照上設定回呼函式更容易使用,因為模組在物件被回收前會自動確 "
115
+ "保最終化器 (finalizer) 保持存活。"
116
116
117
117
#: ../../library/weakref.rst:63
118
118
msgid ""
@@ -188,11 +188,11 @@ msgid ""
188
188
"passed as the only parameter to the callback; the referent will no longer be "
189
189
"available."
190
190
msgstr ""
191
- "傳回對 *object* 的弱參照。如果參照目標仍存活,則可以透過呼叫參照物件來取回原"
191
+ "回傳對 *object* 的弱參照。如果參照目標仍存活,則可以透過呼叫參照物件來取回原"
192
192
"始物件;如果參照目標已不存活,呼叫參照物件將導致 :const:`None` 被回傳。如果 "
193
193
"*callback* 被提供而非 :const:`None`,且回傳的弱參照物件仍存活,那麼當物件即將"
194
- "被終結 (finalize) 時,回呼將被呼叫;弱參照物件將作為唯一的參數傳遞給回呼;參 "
195
- "照物件將不再可用 。"
194
+ "被最終化 (finalize) 時,回呼將被呼叫;弱參照物件將作為唯一的參數傳遞給回呼;"
195
+ "參照物件將不再可用 。"
196
196
197
197
#: ../../library/weakref.rst:108
198
198
msgid ""
@@ -264,7 +264,7 @@ msgid ""
264
264
"keys. *callback* is the same as the parameter of the same name to the :func:"
265
265
"`ref` function."
266
266
msgstr ""
267
- "傳回一個使用弱參照的 *object* 的代理 (proxy)。這支援在大多數情境中使用代理,"
267
+ "回傳一個使用弱參照的 *object* 的代理 (proxy)。這支援在大多數情境中使用代理,"
268
268
"而不需要對弱參照物件明確地取消參照。回傳的物件將具有 ``ProxyType`` 或 "
269
269
"``CallableProxyType`` 型別,具體取決於 *object* 是否為可呼叫物件。無論參照目"
270
270
"標如何,代理物件都不是 :term:`hashable`;這避免了與其基本可變物件本質相關的許"
@@ -340,7 +340,7 @@ msgstr ""
340
340
341
341
#: ../../library/weakref.rst:212
342
342
msgid "Return an iterable of the weak references to the keys."
343
- msgstr "傳回對鍵的弱參照的可疊代物件 。"
343
+ msgstr "回傳對鍵的弱參照的可疊代物件 。"
344
344
345
345
#: ../../library/weakref.rst:217
346
346
msgid ""
@@ -363,7 +363,7 @@ msgstr ""
363
363
364
364
#: ../../library/weakref.rst:229
365
365
msgid "Return an iterable of the weak references to the values."
366
- msgstr "傳回對值的弱參照的可疊代物件 。"
366
+ msgstr "回傳對值的弱參照的可疊代物件 。"
367
367
368
368
#: ../../library/weakref.rst:234
369
369
msgid ""
@@ -399,6 +399,9 @@ msgid ""
399
399
"always survive until the reference object is collected, greatly simplifying "
400
400
"lifecycle management."
401
401
msgstr ""
402
+ "回傳可呼叫的最終化器物件,此物件在 *obj* 被垃圾回收時會被呼叫。與一般的弱參照"
403
+ "不同,最終化器將始終存在,直到參照物件被回收為止,從而大大簡化了生命週期管"
404
+ "理。"
402
405
403
406
#: ../../library/weakref.rst:275
404
407
msgid ""
@@ -407,6 +410,9 @@ msgid ""
407
410
"finalizer returns the result of evaluating ``func(*arg, **kwargs)``, whereas "
408
411
"calling a dead finalizer returns :const:`None`."
409
412
msgstr ""
413
+ "最終化器在被呼叫(明確呼叫或在垃圾回收時)之前被視為\\ *存活*,之後它就會\\ *"
414
+ "死亡*。呼叫存活的最終化器會回傳 ``func(*arg, **kwargs)`` 的計算結果,而呼叫死"
415
+ "亡的最終化器會回傳 :const:`None`。"
410
416
411
417
#: ../../library/weakref.rst:280
412
418
msgid ""
@@ -415,49 +421,63 @@ msgid ""
415
421
"handled in the same way as exceptions raised from an object's :meth:`~object."
416
422
"__del__` method or a weak reference's callback."
417
423
msgstr ""
424
+ "垃圾回收期間最終化器回呼引發的例外會在標準錯誤輸出中顯示,但無法傳播。它們的"
425
+ "處理方式與從物件的 :meth:`~object.__del__` 方法或弱參照的回呼引發的例外相同。"
418
426
419
427
#: ../../library/weakref.rst:286
420
428
msgid ""
421
429
"When the program exits, each remaining live finalizer is called unless its :"
422
430
"attr:`atexit` attribute has been set to false. They are called in reverse "
423
431
"order of creation."
424
432
msgstr ""
433
+ "當程式結束時,除非該最終化器的 :attr:`atexit` 屬性已被設定為 false,否則每個"
434
+ "存活的最終化器會被呼叫。它們以與建立相反的順序被呼叫。"
425
435
426
436
#: ../../library/weakref.rst:290
427
437
msgid ""
428
438
"A finalizer will never invoke its callback during the later part of the :"
429
439
"term:`interpreter shutdown` when module globals are liable to have been "
430
440
"replaced by :const:`None`."
431
441
msgstr ""
442
+ "當模組的 globals 可能被 :const:`None` 取代時,最終化器永遠不會在 :term:"
443
+ "`interpreter shutdown` 的後期調用(invoke)其回呼。"
432
444
433
445
#: ../../library/weakref.rst:296
434
446
msgid ""
435
447
"If *self* is alive then mark it as dead and return the result of calling "
436
448
"``func(*args, **kwargs)``. If *self* is dead then return :const:`None`."
437
449
msgstr ""
450
+ "如果 *self* 仍存活,則將其標記為死亡並回傳呼叫 ``func(*args, **kwargs)`` 的結"
451
+ "果。如果 *self* 已死亡,則回傳 :const:`None`。"
438
452
439
453
#: ../../library/weakref.rst:302
440
454
msgid ""
441
455
"If *self* is alive then mark it as dead and return the tuple ``(obj, func, "
442
456
"args, kwargs)``. If *self* is dead then return :const:`None`."
443
457
msgstr ""
458
+ "如果 *self* 仍存活,則將其標記為死亡並回傳元組 ``(obj, func, args, "
459
+ "kwargs)``。如果 *self* 已死亡,則回傳 :const:`None`。"
444
460
445
461
#: ../../library/weakref.rst:308
446
462
msgid ""
447
463
"If *self* is alive then return the tuple ``(obj, func, args, kwargs)``. If "
448
464
"*self* is dead then return :const:`None`."
449
465
msgstr ""
466
+ "如果 *self* 仍存活,則回傳元組 ``(obj, func, args, kwargs)``。如果 *self* 已"
467
+ "死亡,則回傳 :const:`None`。"
450
468
451
469
#: ../../library/weakref.rst:313
452
470
msgid "Property which is true if the finalizer is alive, false otherwise."
453
- msgstr ""
471
+ msgstr "如果最終化器仍存活,則屬性為 true,否則為 false。 "
454
472
455
473
#: ../../library/weakref.rst:317
456
474
msgid ""
457
475
"A writable boolean property which by default is true. When the program "
458
476
"exits, it calls all remaining live finalizers for which :attr:`.atexit` is "
459
477
"true. They are called in reverse order of creation."
460
478
msgstr ""
479
+ "一個可寫的布林屬性,預設為 true。當程式結束時,它會呼叫 :attr:`.atexit` 為 "
480
+ "true 的所有剩餘且仍存活的最終化器。它們以與建立相反的順序被呼叫。"
461
481
462
482
#: ../../library/weakref.rst:324
463
483
msgid ""
@@ -466,59 +486,67 @@ msgid ""
466
486
"will never be garbage collected. In particular, *func* should not be a "
467
487
"bound method of *obj*."
468
488
msgstr ""
489
+ "確保 *func*、*args* 和 *kwargs* 不直接或間接擁有對 *obj* 的任何參照非常重要,"
490
+ "否則 *obj* 將永遠不會被垃圾回收。尤其 *func* 不應該是 *obj* 的繫結方法。"
469
491
470
492
#: ../../library/weakref.rst:334
471
493
msgid "The type object for weak references objects."
472
- msgstr ""
494
+ msgstr "弱參照物件的型別物件。 "
473
495
474
496
#: ../../library/weakref.rst:339
475
497
msgid "The type object for proxies of objects which are not callable."
476
- msgstr ""
498
+ msgstr "非可呼叫物件的代理的型別物件。 "
477
499
478
500
#: ../../library/weakref.rst:344
479
501
msgid "The type object for proxies of callable objects."
480
- msgstr ""
502
+ msgstr "可呼叫物件的代理的型別物件。 "
481
503
482
504
#: ../../library/weakref.rst:349
483
505
msgid ""
484
506
"Sequence containing all the type objects for proxies. This can make it "
485
507
"simpler to test if an object is a proxy without being dependent on naming "
486
508
"both proxy types."
487
509
msgstr ""
510
+ "包含代理的所有型別物件的序列。這可以讓測試物件是否為代理變得更簡單,而無需依"
511
+ "賴命名兩種代理型別。"
488
512
489
513
#: ../../library/weakref.rst:356
490
514
msgid ":pep:`205` - Weak References"
491
- msgstr ""
515
+ msgstr ":pep:`205` - 弱參照 "
492
516
493
517
#: ../../library/weakref.rst:357
494
518
msgid ""
495
519
"The proposal and rationale for this feature, including links to earlier "
496
520
"implementations and information about similar features in other languages."
497
- msgstr ""
521
+ msgstr "此功能的提案和理由,包括早期實作的連結以及其他語言中類似功能的資訊。 "
498
522
499
523
#: ../../library/weakref.rst:364
500
524
msgid "Weak Reference Objects"
501
- msgstr ""
525
+ msgstr "弱參照物件 "
502
526
503
527
#: ../../library/weakref.rst:366
504
528
msgid ""
505
529
"Weak reference objects have no methods and no attributes besides :attr:`ref."
506
530
"__callback__`. A weak reference object allows the referent to be obtained, "
507
531
"if it still exists, by calling it:"
508
532
msgstr ""
533
+ "弱參照物件除了 :attr:`ref.__callback__` 之外沒有任何方法和屬性。弱參照物件允"
534
+ "許透過呼叫來獲取參照目標(如果它仍然存在):"
509
535
510
536
#: ../../library/weakref.rst:380
511
537
msgid ""
512
538
"If the referent no longer exists, calling the reference object returns :"
513
539
"const:`None`:"
514
- msgstr ""
540
+ msgstr "如果參照目標不再存活,則呼叫參照物件將回傳 :const:`None`: "
515
541
516
542
#: ../../library/weakref.rst:387
517
543
msgid ""
518
544
"Testing that a weak reference object is still live should be done using the "
519
545
"expression ``ref() is not None``. Normally, application code that needs to "
520
546
"use a reference object should follow this pattern::"
521
547
msgstr ""
548
+ "應該使用運算式 ``ref() is not None`` 來測試弱參照物件是否仍然存活。需要使用參"
549
+ "照物件的應用程式程式碼通常應遵循以下模式: ::"
522
550
523
551
#: ../../library/weakref.rst:400
524
552
msgid ""
@@ -527,6 +555,9 @@ msgid ""
527
555
"invalidated before the weak reference is called; the idiom shown above is "
528
556
"safe in threaded applications as well as single-threaded applications."
529
557
msgstr ""
558
+ "使用對「活性 (liveness)」的單獨測試會在執行緒應用程式中建立競爭條件 (race "
559
+ "condition);另一個執行緒可能在弱參照被呼叫之前讓該弱參照失效;上方顯示的慣用"
560
+ "作法在執行緒應用程式和單執行緒應用程式中都是安全的。"
530
561
531
562
#: ../../library/weakref.rst:405
532
563
msgid ""
@@ -537,13 +568,19 @@ msgid ""
537
568
"reference, but could also be used to insert additional processing on calls "
538
569
"to retrieve the referent."
539
570
msgstr ""
571
+ "可以透過子類別化來建立 :class:`ref` 物件的特殊版本。這在 :class:"
572
+ "`WeakValueDictionary` 的實作中被使用,以減少對映中每個條目的記憶體開銷。這對"
573
+ "於將附加資訊與參照相關聯最有用,但也可用於在呼叫上插入附加處理以檢索參照目"
574
+ "標。"
540
575
541
576
#: ../../library/weakref.rst:411
542
577
msgid ""
543
578
"This example shows how a subclass of :class:`ref` can be used to store "
544
579
"additional information about an object and affect the value that's returned "
545
580
"when the referent is accessed::"
546
581
msgstr ""
582
+ "這個範例展示如何使用 :class:`ref` 的子類別來儲存有關物件的附加資訊並影響存取"
583
+ "參照目標時回傳的值: ::"
547
584
548
585
#: ../../library/weakref.rst:438
549
586
msgid "Example"
@@ -556,66 +593,78 @@ msgid ""
556
593
"other data structures without forcing the objects to remain alive, but the "
557
594
"objects can still be retrieved by ID if they do."
558
595
msgstr ""
596
+ "這個簡單的範例展示了應用程式如何使用物件 ID 來檢索它以前見過的物件。物件的 "
597
+ "ID 之後可以在其他資料結構中使用,而不必強制物件保持存活,但如果這樣做,仍然可"
598
+ "以透過 ID 檢索物件。"
559
599
560
600
#: ../../library/weakref.rst:465
561
601
msgid "Finalizer Objects"
562
- msgstr ""
602
+ msgstr "最終化器物件 "
563
603
564
604
#: ../../library/weakref.rst:467
565
605
msgid ""
566
606
"The main benefit of using :class:`finalize` is that it makes it simple to "
567
607
"register a callback without needing to preserve the returned finalizer "
568
608
"object. For instance"
569
609
msgstr ""
610
+ "使用 :class:`finalize` 的最大優點是可以輕鬆註冊回呼,而無需保留回傳的最終化器"
611
+ "物件。例如"
570
612
571
613
#: ../../library/weakref.rst:481
572
614
msgid ""
573
615
"The finalizer can be called directly as well. However the finalizer will "
574
616
"invoke the callback at most once."
575
- msgstr ""
617
+ msgstr "最終化器也可以直接被呼叫。然而,最終化器最多會調用回呼一次。 "
576
618
577
619
#: ../../library/weakref.rst:497
578
620
msgid ""
579
621
"You can unregister a finalizer using its :meth:`~finalize.detach` method. "
580
622
"This kills the finalizer and returns the arguments passed to the constructor "
581
623
"when it was created."
582
624
msgstr ""
625
+ "你可以使用最終化器的 :meth:`~finalize.detach` 方法來取消註冊最終化器。這會殺"
626
+ "死最終化器並回傳建立建構函式時傳遞給建構函式的引數。"
583
627
584
628
#: ../../library/weakref.rst:511
585
629
msgid ""
586
630
"Unless you set the :attr:`~finalize.atexit` attribute to :const:`False`, a "
587
631
"finalizer will be called when the program exits if it is still alive. For "
588
632
"instance"
589
633
msgstr ""
634
+ "除非你將 :attr:`~finalize.atexit` 屬性設為 :const:`False`,否則當程式結束時,"
635
+ "最終化器將會被呼叫如果其仍然存在。例如"
590
636
591
637
#: ../../library/weakref.rst:526
592
638
msgid "Comparing finalizers with :meth:`~object.__del__` methods"
593
- msgstr ""
639
+ msgstr "最終化器與 :meth:`~object.__del__` 方法的比較 "
594
640
595
641
#: ../../library/weakref.rst:528
596
642
msgid ""
597
643
"Suppose we want to create a class whose instances represent temporary "
598
644
"directories. The directories should be deleted with their contents when the "
599
645
"first of the following events occurs:"
600
646
msgstr ""
647
+ "假設我們要建立一個類別,其實例代表臨時目錄。當以下任一事件發生時,應刪除目錄"
648
+ "及其內容:"
601
649
602
650
#: ../../library/weakref.rst:532
603
651
msgid "the object is garbage collected,"
604
- msgstr ""
652
+ msgstr "該物件被垃圾回收, "
605
653
606
654
#: ../../library/weakref.rst:533
607
655
msgid "the object's :meth:`!remove` method is called, or"
608
- msgstr ""
656
+ msgstr "該物件的 :meth:`!remove` 方法被呼叫,或者 "
609
657
610
658
#: ../../library/weakref.rst:534
611
659
msgid "the program exits."
612
- msgstr ""
660
+ msgstr "程式結束。 "
613
661
614
662
#: ../../library/weakref.rst:536
615
663
msgid ""
616
664
"We might try to implement the class using a :meth:`~object.__del__` method "
617
665
"as follows::"
618
666
msgstr ""
667
+ "我們可以用以下的方式來嘗試使用 :meth:`~object.__del__` 方法實作該類別: ::"
619
668
620
669
#: ../../library/weakref.rst:555
621
670
msgid ""
@@ -624,34 +673,45 @@ msgid ""
624
673
"longer forced to :const:`None` during :term:`interpreter shutdown`. So this "
625
674
"code should work without any issues on CPython."
626
675
msgstr ""
676
+ "從 Python 3.4 開始,:meth:`~object.__del__` 方法不再阻止參照循環 (reference "
677
+ "cycle) 被垃圾回收,並且在 :term:`interpreter shutdown` 期間不再強制將模組的 "
678
+ "globals 設為 :const:`None`。所以這段程式碼在 CPython 上應該可以正常運作。"
627
679
628
680
#: ../../library/weakref.rst:560
629
681
msgid ""
630
682
"However, handling of :meth:`~object.__del__` methods is notoriously "
631
683
"implementation specific, since it depends on internal details of the "
632
684
"interpreter's garbage collector implementation."
633
685
msgstr ""
686
+ "然而,眾所周知,對 :meth:`~object.__del__` 方法的處理是特地實作的,因為它依賴"
687
+ "於直譯器的垃圾回收器實作的內部細節。"
634
688
635
689
#: ../../library/weakref.rst:564
636
690
msgid ""
637
691
"A more robust alternative can be to define a finalizer which only references "
638
692
"the specific functions and objects that it needs, rather than having access "
639
693
"to the full state of the object::"
640
694
msgstr ""
695
+ "更耐用的替代方案可以是定義一個最終化器,其僅參照需要的特定函式和物件,而不是"
696
+ "存取物件的完整狀態: ::"
641
697
642
698
#: ../../library/weakref.rst:580
643
699
msgid ""
644
700
"Defined like this, our finalizer only receives a reference to the details it "
645
701
"needs to clean up the directory appropriately. If the object never gets "
646
702
"garbage collected the finalizer will still be called at exit."
647
703
msgstr ""
704
+ "定義如下,我們的最終化器僅接收對適當清理目錄所需的詳細資訊的參照。如果物件從"
705
+ "未被垃圾回收,則最終化器仍將在結束時被呼叫。"
648
706
649
707
#: ../../library/weakref.rst:584
650
708
msgid ""
651
709
"The other advantage of weakref based finalizers is that they can be used to "
652
710
"register finalizers for classes where the definition is controlled by a "
653
711
"third party, such as running code when a module is unloaded::"
654
712
msgstr ""
713
+ "基於 weakref 的最終化器的另一個優點是它們可用於為定義由第三方控制的類別註冊最"
714
+ "終化器,例如在卸載模組時執行程式碼: ::"
655
715
656
716
#: ../../library/weakref.rst:596
657
717
msgid ""
@@ -660,3 +720,6 @@ msgid ""
660
720
"at exit. However, in a daemonic thread :func:`atexit.register`, ``try: ... "
661
721
"finally: ...`` and ``with: ...`` do not guarantee that cleanup occurs either."
662
722
msgstr ""
723
+ "如果在程式結束時在常駐的 (daemonic) 執行緒中建立最終化器物件,則最終化器有可"
724
+ "能在結束時不會被呼叫。然而,在常駐的執行緒中 :func:`atexit.register`、"
725
+ "``try: ... finally: ...`` 和 ``with: ...`` 也不保證清理會發生。"
0 commit comments