Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit29fd773

Browse files
authored
translate-weakref (#904)
1 parent6fcd273 commit29fd773

File tree

1 file changed

+87
-24
lines changed

1 file changed

+87
-24
lines changed

‎library/weakref.po

Lines changed: 87 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgstr ""
88
"Project-Id-Version:Python 3.12\n"
99
"Report-Msgid-Bugs-To:\n"
1010
"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"
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,7 +17,7 @@ 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"
20+
"X-Generator:Poedit 3.4.4\n"
2121

2222
#:../../library/weakref.rst:4
2323
msgid":mod:`weakref` --- Weak references"
@@ -111,8 +111,8 @@ msgid ""
111111
"object is collected."
112112
msgstr""
113113
":class:`finalize` 提供了一種直接的方法來註冊在物件被垃圾回收時呼叫的清理函"
114-
"式。這比在原始弱參照上設定回呼函式更容易使用,因為模組在物件被收集前會自動確"
115-
"保終結函式 (finalizer) 保持存活。"
114+
"式。這比在原始弱參照上設定回呼函式更容易使用,因為模組在物件被回收前會自動確"
115+
"保最終化器 (finalizer) 保持存活。"
116116

117117
#:../../library/weakref.rst:63
118118
msgid""
@@ -188,11 +188,11 @@ msgid ""
188188
"passed as the only parameter to the callback; the referent will no longer be "
189189
"available."
190190
msgstr""
191-
"傳回對 *object* 的弱參照。如果參照目標仍存活,則可以透過呼叫參照物件來取回原"
191+
"回傳對 *object* 的弱參照。如果參照目標仍存活,則可以透過呼叫參照物件來取回原"
192192
"始物件;如果參照目標已不存活,呼叫參照物件將導致 :const:`None` 被回傳。如果 "
193193
"*callback* 被提供而非 :const:`None`,且回傳的弱參照物件仍存活,那麼當物件即將"
194-
"被終結 (finalize) 時,回呼將被呼叫;弱參照物件將作為唯一的參數傳遞給回呼;"
195-
"照物件將不再可用。"
194+
"被最終化 (finalize) 時,回呼將被呼叫;弱參照物件將作為唯一的參數傳遞給回呼;"
195+
"參照物件將不再可用。"
196196

197197
#:../../library/weakref.rst:108
198198
msgid""
@@ -264,7 +264,7 @@ msgid ""
264264
"keys. *callback* is the same as the parameter of the same name to the :func:"
265265
"`ref` function."
266266
msgstr""
267-
"傳回一個使用弱參照的 *object* 的代理 (proxy)。這支援在大多數情境中使用代理,"
267+
"回傳一個使用弱參照的 *object* 的代理 (proxy)。這支援在大多數情境中使用代理,"
268268
"而不需要對弱參照物件明確地取消參照。回傳的物件將具有 ``ProxyType`` 或 "
269269
"``CallableProxyType`` 型別,具體取決於 *object* 是否為可呼叫物件。無論參照目"
270270
"標如何,代理物件都不是 :term:`hashable`;這避免了與其基本可變物件本質相關的許"
@@ -340,7 +340,7 @@ msgstr ""
340340

341341
#:../../library/weakref.rst:212
342342
msgid"Return an iterable of the weak references to the keys."
343-
msgstr"傳回對鍵的弱參照的可疊代物件。"
343+
msgstr"回傳對鍵的弱參照的可疊代物件。"
344344

345345
#:../../library/weakref.rst:217
346346
msgid""
@@ -363,7 +363,7 @@ msgstr ""
363363

364364
#:../../library/weakref.rst:229
365365
msgid"Return an iterable of the weak references to the values."
366-
msgstr"傳回對值的弱參照的可疊代物件。"
366+
msgstr"回傳對值的弱參照的可疊代物件。"
367367

368368
#:../../library/weakref.rst:234
369369
msgid""
@@ -399,6 +399,9 @@ msgid ""
399399
"always survive until the reference object is collected, greatly simplifying "
400400
"lifecycle management."
401401
msgstr""
402+
"回傳可呼叫的最終化器物件,此物件在 *obj* 被垃圾回收時會被呼叫。與一般的弱參照"
403+
"不同,最終化器將始終存在,直到參照物件被回收為止,從而大大簡化了生命週期管"
404+
"理。"
402405

403406
#:../../library/weakref.rst:275
404407
msgid""
@@ -407,6 +410,9 @@ msgid ""
407410
"finalizer returns the result of evaluating ``func(*arg, **kwargs)``, whereas "
408411
"calling a dead finalizer returns :const:`None`."
409412
msgstr""
413+
"最終化器在被呼叫(明確呼叫或在垃圾回收時)之前被視為\\ *存活*,之後它就會\\ *"
414+
"死亡*。呼叫存活的最終化器會回傳 ``func(*arg, **kwargs)`` 的計算結果,而呼叫死"
415+
"亡的最終化器會回傳 :const:`None`。"
410416

411417
#:../../library/weakref.rst:280
412418
msgid""
@@ -415,49 +421,63 @@ msgid ""
415421
"handled in the same way as exceptions raised from an object's :meth:`~object."
416422
"__del__` method or a weak reference's callback."
417423
msgstr""
424+
"垃圾回收期間最終化器回呼引發的例外會在標準錯誤輸出中顯示,但無法傳播。它們的"
425+
"處理方式與從物件的 :meth:`~object.__del__` 方法或弱參照的回呼引發的例外相同。"
418426

419427
#:../../library/weakref.rst:286
420428
msgid""
421429
"When the program exits, each remaining live finalizer is called unless its :"
422430
"attr:`atexit` attribute has been set to false. They are called in reverse "
423431
"order of creation."
424432
msgstr""
433+
"當程式結束時,除非該最終化器的 :attr:`atexit` 屬性已被設定為 false,否則每個"
434+
"存活的最終化器會被呼叫。它們以與建立相反的順序被呼叫。"
425435

426436
#:../../library/weakref.rst:290
427437
msgid""
428438
"A finalizer will never invoke its callback during the later part of the :"
429439
"term:`interpreter shutdown` when module globals are liable to have been "
430440
"replaced by :const:`None`."
431441
msgstr""
442+
"當模組的 globals 可能被 :const:`None` 取代時,最終化器永遠不會在 :term:"
443+
"`interpreter shutdown` 的後期調用(invoke)其回呼。"
432444

433445
#:../../library/weakref.rst:296
434446
msgid""
435447
"If *self* is alive then mark it as dead and return the result of calling "
436448
"``func(*args, **kwargs)``. If *self* is dead then return :const:`None`."
437449
msgstr""
450+
"如果 *self* 仍存活,則將其標記為死亡並回傳呼叫 ``func(*args, **kwargs)`` 的結"
451+
"果。如果 *self* 已死亡,則回傳 :const:`None`。"
438452

439453
#:../../library/weakref.rst:302
440454
msgid""
441455
"If *self* is alive then mark it as dead and return the tuple ``(obj, func, "
442456
"args, kwargs)``. If *self* is dead then return :const:`None`."
443457
msgstr""
458+
"如果 *self* 仍存活,則將其標記為死亡並回傳元組 ``(obj, func, args, "
459+
"kwargs)``。如果 *self* 已死亡,則回傳 :const:`None`。"
444460

445461
#:../../library/weakref.rst:308
446462
msgid""
447463
"If *self* is alive then return the tuple ``(obj, func, args, kwargs)``. If "
448464
"*self* is dead then return :const:`None`."
449465
msgstr""
466+
"如果 *self* 仍存活,則回傳元組 ``(obj, func, args, kwargs)``。如果 *self* 已"
467+
"死亡,則回傳 :const:`None`。"
450468

451469
#:../../library/weakref.rst:313
452470
msgid"Property which is true if the finalizer is alive, false otherwise."
453-
msgstr""
471+
msgstr"如果最終化器仍存活,則屬性為 true,否則為 false。"
454472

455473
#:../../library/weakref.rst:317
456474
msgid""
457475
"A writable boolean property which by default is true. When the program "
458476
"exits, it calls all remaining live finalizers for which :attr:`.atexit` is "
459477
"true. They are called in reverse order of creation."
460478
msgstr""
479+
"一個可寫的布林屬性,預設為 true。當程式結束時,它會呼叫 :attr:`.atexit` 為 "
480+
"true 的所有剩餘且仍存活的最終化器。它們以與建立相反的順序被呼叫。"
461481

462482
#:../../library/weakref.rst:324
463483
msgid""
@@ -466,59 +486,67 @@ msgid ""
466486
"will never be garbage collected. In particular, *func* should not be a "
467487
"bound method of *obj*."
468488
msgstr""
489+
"確保 *func*、*args* 和 *kwargs* 不直接或間接擁有對 *obj* 的任何參照非常重要,"
490+
"否則 *obj* 將永遠不會被垃圾回收。尤其 *func* 不應該是 *obj* 的繫結方法。"
469491

470492
#:../../library/weakref.rst:334
471493
msgid"The type object for weak references objects."
472-
msgstr""
494+
msgstr"弱參照物件的型別物件。"
473495

474496
#:../../library/weakref.rst:339
475497
msgid"The type object for proxies of objects which are not callable."
476-
msgstr""
498+
msgstr"非可呼叫物件的代理的型別物件。"
477499

478500
#:../../library/weakref.rst:344
479501
msgid"The type object for proxies of callable objects."
480-
msgstr""
502+
msgstr"可呼叫物件的代理的型別物件。"
481503

482504
#:../../library/weakref.rst:349
483505
msgid""
484506
"Sequence containing all the type objects for proxies. This can make it "
485507
"simpler to test if an object is a proxy without being dependent on naming "
486508
"both proxy types."
487509
msgstr""
510+
"包含代理的所有型別物件的序列。這可以讓測試物件是否為代理變得更簡單,而無需依"
511+
"賴命名兩種代理型別。"
488512

489513
#:../../library/weakref.rst:356
490514
msgid":pep:`205` - Weak References"
491-
msgstr""
515+
msgstr":pep:`205` - 弱參照"
492516

493517
#:../../library/weakref.rst:357
494518
msgid""
495519
"The proposal and rationale for this feature, including links to earlier "
496520
"implementations and information about similar features in other languages."
497-
msgstr""
521+
msgstr"此功能的提案和理由,包括早期實作的連結以及其他語言中類似功能的資訊。"
498522

499523
#:../../library/weakref.rst:364
500524
msgid"Weak Reference Objects"
501-
msgstr""
525+
msgstr"弱參照物件"
502526

503527
#:../../library/weakref.rst:366
504528
msgid""
505529
"Weak reference objects have no methods and no attributes besides :attr:`ref."
506530
"__callback__`. A weak reference object allows the referent to be obtained, "
507531
"if it still exists, by calling it:"
508532
msgstr""
533+
"弱參照物件除了 :attr:`ref.__callback__` 之外沒有任何方法和屬性。弱參照物件允"
534+
"許透過呼叫來獲取參照目標(如果它仍然存在):"
509535

510536
#:../../library/weakref.rst:380
511537
msgid""
512538
"If the referent no longer exists, calling the reference object returns :"
513539
"const:`None`:"
514-
msgstr""
540+
msgstr"如果參照目標不再存活,則呼叫參照物件將回傳 :const:`None`:"
515541

516542
#:../../library/weakref.rst:387
517543
msgid""
518544
"Testing that a weak reference object is still live should be done using the "
519545
"expression ``ref() is not None``. Normally, application code that needs to "
520546
"use a reference object should follow this pattern::"
521547
msgstr""
548+
"應該使用運算式 ``ref() is not None`` 來測試弱參照物件是否仍然存活。需要使用參"
549+
"照物件的應用程式程式碼通常應遵循以下模式: ::"
522550

523551
#:../../library/weakref.rst:400
524552
msgid""
@@ -527,6 +555,9 @@ msgid ""
527555
"invalidated before the weak reference is called; the idiom shown above is "
528556
"safe in threaded applications as well as single-threaded applications."
529557
msgstr""
558+
"使用對「活性 (liveness)」的單獨測試會在執行緒應用程式中建立競爭條件 (race "
559+
"condition);另一個執行緒可能在弱參照被呼叫之前讓該弱參照失效;上方顯示的慣用"
560+
"作法在執行緒應用程式和單執行緒應用程式中都是安全的。"
530561

531562
#:../../library/weakref.rst:405
532563
msgid""
@@ -537,13 +568,19 @@ msgid ""
537568
"reference, but could also be used to insert additional processing on calls "
538569
"to retrieve the referent."
539570
msgstr""
571+
"可以透過子類別化來建立 :class:`ref` 物件的特殊版本。這在 :class:"
572+
"`WeakValueDictionary` 的實作中被使用,以減少對映中每個條目的記憶體開銷。這對"
573+
"於將附加資訊與參照相關聯最有用,但也可用於在呼叫上插入附加處理以檢索參照目"
574+
"標。"
540575

541576
#:../../library/weakref.rst:411
542577
msgid""
543578
"This example shows how a subclass of :class:`ref` can be used to store "
544579
"additional information about an object and affect the value that's returned "
545580
"when the referent is accessed::"
546581
msgstr""
582+
"這個範例展示如何使用 :class:`ref` 的子類別來儲存有關物件的附加資訊並影響存取"
583+
"參照目標時回傳的值: ::"
547584

548585
#:../../library/weakref.rst:438
549586
msgid"Example"
@@ -556,66 +593,78 @@ msgid ""
556593
"other data structures without forcing the objects to remain alive, but the "
557594
"objects can still be retrieved by ID if they do."
558595
msgstr""
596+
"這個簡單的範例展示了應用程式如何使用物件 ID 來檢索它以前見過​​的物件。物件的 "
597+
"ID 之後可以在其他資料結構中使用,而不必強制物件保持存活,但如果這樣做,仍然可"
598+
"以透過 ID 檢索物件。"
559599

560600
#:../../library/weakref.rst:465
561601
msgid"Finalizer Objects"
562-
msgstr""
602+
msgstr"最終化器物件"
563603

564604
#:../../library/weakref.rst:467
565605
msgid""
566606
"The main benefit of using :class:`finalize` is that it makes it simple to "
567607
"register a callback without needing to preserve the returned finalizer "
568608
"object. For instance"
569609
msgstr""
610+
"使用 :class:`finalize` 的最大優點是可以輕鬆註冊回呼,而無需保留回傳的最終化器"
611+
"物件。例如"
570612

571613
#:../../library/weakref.rst:481
572614
msgid""
573615
"The finalizer can be called directly as well. However the finalizer will "
574616
"invoke the callback at most once."
575-
msgstr""
617+
msgstr"最終化器也可以直接被呼叫。然而,最終化器最多會調用回呼一次。"
576618

577619
#:../../library/weakref.rst:497
578620
msgid""
579621
"You can unregister a finalizer using its :meth:`~finalize.detach` method. "
580622
"This kills the finalizer and returns the arguments passed to the constructor "
581623
"when it was created."
582624
msgstr""
625+
"你可以使用最終化器的 :meth:`~finalize.detach` 方法來取消註冊最終化器。這會殺"
626+
"死最終化器並回傳建立建構函式時傳遞給建構函式的引數。"
583627

584628
#:../../library/weakref.rst:511
585629
msgid""
586630
"Unless you set the :attr:`~finalize.atexit` attribute to :const:`False`, a "
587631
"finalizer will be called when the program exits if it is still alive. For "
588632
"instance"
589633
msgstr""
634+
"除非你將 :attr:`~finalize.atexit` 屬性設為 :const:`False`,否則當程式結束時,"
635+
"最終化器將會被呼叫如果其仍然存在。例如"
590636

591637
#:../../library/weakref.rst:526
592638
msgid"Comparing finalizers with :meth:`~object.__del__` methods"
593-
msgstr""
639+
msgstr"最終化器與 :meth:`~object.__del__` 方法的比較"
594640

595641
#:../../library/weakref.rst:528
596642
msgid""
597643
"Suppose we want to create a class whose instances represent temporary "
598644
"directories. The directories should be deleted with their contents when the "
599645
"first of the following events occurs:"
600646
msgstr""
647+
"假設我們要建立一個類別,其實例代表臨時目錄。當以下任一事件發生時,應刪除目錄"
648+
"及其內容:"
601649

602650
#:../../library/weakref.rst:532
603651
msgid"the object is garbage collected,"
604-
msgstr""
652+
msgstr"該物件被垃圾回收,"
605653

606654
#:../../library/weakref.rst:533
607655
msgid"the object's :meth:`!remove` method is called, or"
608-
msgstr""
656+
msgstr"該物件的 :meth:`!remove` 方法被呼叫,或者"
609657

610658
#:../../library/weakref.rst:534
611659
msgid"the program exits."
612-
msgstr""
660+
msgstr"程式結束。"
613661

614662
#:../../library/weakref.rst:536
615663
msgid""
616664
"We might try to implement the class using a :meth:`~object.__del__` method "
617665
"as follows::"
618666
msgstr""
667+
"我們可以用以下的方式來嘗試使用 :meth:`~object.__del__` 方法實作該類別: ::"
619668

620669
#:../../library/weakref.rst:555
621670
msgid""
@@ -624,34 +673,45 @@ msgid ""
624673
"longer forced to :const:`None` during :term:`interpreter shutdown`. So this "
625674
"code should work without any issues on CPython."
626675
msgstr""
676+
"從 Python 3.4 開始,:meth:`~object.__del__` 方法不再阻止參照循環 (reference "
677+
"cycle) 被垃圾回收,並且在 :term:`interpreter shutdown` 期間不再強制將模組的 "
678+
"globals 設為 :const:`None`。所以這段程式碼在 CPython 上應該可以正常運作。"
627679

628680
#:../../library/weakref.rst:560
629681
msgid""
630682
"However, handling of :meth:`~object.__del__` methods is notoriously "
631683
"implementation specific, since it depends on internal details of the "
632684
"interpreter's garbage collector implementation."
633685
msgstr""
686+
"然而,眾所周知,對 :meth:`~object.__del__` 方法的處理是特地實作的,因為它依賴"
687+
"於直譯器的垃圾回收器實作的內部細節。"
634688

635689
#:../../library/weakref.rst:564
636690
msgid""
637691
"A more robust alternative can be to define a finalizer which only references "
638692
"the specific functions and objects that it needs, rather than having access "
639693
"to the full state of the object::"
640694
msgstr""
695+
"更耐用的替代方案可以是定義一個最終化器,其僅參照需要的特定函式和物件,而不是"
696+
"存取物件的完整狀態: ::"
641697

642698
#:../../library/weakref.rst:580
643699
msgid""
644700
"Defined like this, our finalizer only receives a reference to the details it "
645701
"needs to clean up the directory appropriately. If the object never gets "
646702
"garbage collected the finalizer will still be called at exit."
647703
msgstr""
704+
"定義如下,我們的最終化器僅接收對適當清理目錄所需的詳細資訊的參照。如果物件從"
705+
"未被垃圾回收,則最終化器仍將在結束時被呼叫。"
648706

649707
#:../../library/weakref.rst:584
650708
msgid""
651709
"The other advantage of weakref based finalizers is that they can be used to "
652710
"register finalizers for classes where the definition is controlled by a "
653711
"third party, such as running code when a module is unloaded::"
654712
msgstr""
713+
"基於 weakref 的最終化器的另一個優點是它們可用於為定義由第三方控制的類別註冊最"
714+
"終化器,例如在卸載模組時執行程式碼: ::"
655715

656716
#:../../library/weakref.rst:596
657717
msgid""
@@ -660,3 +720,6 @@ msgid ""
660720
"at exit. However, in a daemonic thread :func:`atexit.register`, ``try: ... "
661721
"finally: ...`` and ``with: ...`` do not guarantee that cleanup occurs either."
662722
msgstr""
723+
"如果在程式結束時在常駐的 (daemonic) 執行緒中建立最終化器物件,則最終化器有可"
724+
"能在結束時不會被呼叫。然而,在常駐的執行緒中 :func:`atexit.register`、"
725+
"``try: ... finally: ...`` 和 ``with: ...`` 也不保證清理會發生。"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp