diff --git a/library/re.po b/library/re.po index 6474df8f64..9a3cea8d64 100644 --- a/library/re.po +++ b/library/re.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-08-27 00:04+0000\n" -"PO-Revision-Date: 2023-05-20 13:44+0800\n" +"PO-Revision-Date: 2023-09-16 14:49+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -18,7 +18,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 3.3.1\n" +"X-Generator: Poedit 3.3.2\n" #: ../../library/re.rst:2 msgid ":mod:`re` --- Regular expression operations" @@ -32,8 +32,7 @@ msgstr "**原始碼:**\\ :source:`Lib/re/`" msgid "" "This module provides regular expression matching operations similar to those " "found in Perl." -msgstr "" -"此模組提供類似於 Perl 中正規表示式的配對操作。" +msgstr "此模組提供類似於 Perl 中正規表示式的配對操作。" #: ../../library/re.rst:17 msgid "" @@ -44,10 +43,10 @@ msgid "" "substitution, the replacement string must be of the same type as both the " "pattern and the search string." msgstr "" -"被搜尋的模式 (pattern) 與字串可以是 Unicode 字串 (:class:`str`),也可以是 8-bit " -"字串 (:class:`bytes`)。然而,Unicode 字串和 8-bit 字串不能混用:也就是,你不能用 " -"byte 模式配對 Unicode 字串,反之亦然;同樣地,替換時,用來替換的字串必須與模式和搜尋" -"字串是相同的型別 (type)。" +"被搜尋的模式 (pattern) 與字串可以是 Unicode 字串 (:class:`str`),也可以是 8-" +"bit 字串 (:class:`bytes`)。然而,Unicode 字串和 8-bit 字串不能混用:也就是," +"你不能用 byte 模式配對 Unicode 字串,反之亦然;同樣地,替換時,用來替換的字串" +"必須與模式和搜尋字串是相同的型別 (type)。" #: ../../library/re.rst:24 msgid "" @@ -64,12 +63,13 @@ msgid "" "even if it is a valid escape sequence for a regular expression." msgstr "" "正規表示式使用反斜線字元 (``'\\'``) 表示特別的形式,或是使用特殊字元而不調用" -"它們的特殊意義。這與 Python 在字串文本 (literal) 中,為了一樣的目的使用同一個字元的" -"目的相衝突;舉例來說,為了配對一個反斜線文字,一個人可能需要寫 ``'\\\\\\\\'`` 當作" -"模式字串,因為正規表示式必須是 ``\\\\``,而且每個反斜線在一個普通的 Python 字串文本中" -"必須表示為 ``\\\\``。另外,請注意在 Python 的字串文本中使用反斜線的任何無效跳脫序列" -"目前會產生一個 :exc:`SyntaxWarning`,而在未來這會變成一個 :exc:`SyntaxError`。" -"儘管它對正規表示式是一個有效的跳脫序列,這種行為也會發生。" +"它們的特殊意義。這與 Python 在字串文本 (literal) 中,為了一樣的目的使用同一個" +"字元的目的相衝突;舉例來說,為了配對一個反斜線文字,一個人可能需要寫 ``'\\\\" +"\\\\'`` 當作模式字串,因為正規表示式必須是 ``\\\\``,而且每個反斜線在一個普通" +"的 Python 字串文本中必須表示為 ``\\\\``。另外,請注意在 Python 的字串文本中使" +"用反斜線的任何無效跳脫序列目前會產生一個 :exc:`SyntaxWarning`,而在未來這會變" +"成一個 :exc:`SyntaxError`。儘管它對正規表示式是一個有效的跳脫序列,這種行為也" +"會發生。" #: ../../library/re.rst:36 msgid "" @@ -80,10 +80,10 @@ msgid "" "a newline. Usually patterns will be expressed in Python code using this raw " "string notation." msgstr "" -"解決方法是對正規表示式模式使用 Python 的原始字串符號;反斜線在一個以 ``'r'`` 為前綴" -"的字串文本中不會被用任何特別的方式處理。所以 ``r\"\\n\"`` 是一個兩個字元的字串,包含" -" ``'\\'`` 和 ``'n'``,同時 ``\"\\n\"`` 是一個單個字元的字串,包含一個換行符號。通常" -"模式在 Python 程式中會使用這個原始字串符號表示。" +"解決方法是對正規表示式模式使用 Python 的原始字串符號;反斜線在一個以 ``'r'`` " +"為前綴的字串文本中不會被用任何特別的方式處理。所以 ``r\"\\n\"`` 是一個兩個字" +"元的字串,包含 ``'\\'`` 和 ``'n'``,同時 ``\"\\n\"`` 是一個單個字元的字串,包" +"含一個換行符號。通常模式在 Python 程式中會使用這個原始字串符號表示。" #: ../../library/re.rst:43 msgid "" @@ -92,9 +92,9 @@ msgid "" "expressions `. The functions are shortcuts that don't require " "you to compile a regex object first, but miss some fine-tuning parameters." msgstr "" -"請務必注意到大部分的正規表示式操作是可以在模組層級的函式和 :ref:`" -"compiled regular expressions ` 中的方法使用的。這些函式是個捷徑" -"且讓你不需要先編譯一個正規表示式物件,但是會缺少一些微調參數。" +"請務必注意到大部分的正規表示式操作是可以在模組層級的函式和 :ref:`compiled " +"regular expressions ` 中的方法使用的。這些函式是個捷徑且讓你不需" +"要先編譯一個正規表示式物件,但是會缺少一些微調參數。" #: ../../library/re.rst:51 msgid "" @@ -102,12 +102,12 @@ msgid "" "an API compatible with the standard library :mod:`re` module, but offers " "additional functionality and a more thorough Unicode support." msgstr "" -"第三方的 `regex `_ 模組,有著和標準函式庫" -" :mod:`re` 模組相容的 API,但是提供額外的功能以及更完整的 Unicode 支援。" +"第三方的 `regex `_ 模組,有著和標準函式庫 :" +"mod:`re` 模組相容的 API,但是提供額外的功能以及更完整的 Unicode 支援。" #: ../../library/re.rst:59 msgid "Regular Expression Syntax" -msgstr "" +msgstr "正規表示式語法" #: ../../library/re.rst:61 msgid "" diff --git a/library/timeit.po b/library/timeit.po index 3682b031a4..e750ba6a16 100644 --- a/library/timeit.po +++ b/library/timeit.po @@ -1,15 +1,16 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2023, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: +# Adrian Liaw , 2018 +# Matt Wang , 2023 msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-08-27 18:15+0000\n" "PO-Revision-Date: 2023-05-20 13:21+0800\n" -"Last-Translator: Adrian Liaw \n" +"Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -35,6 +36,11 @@ msgid "" "execution times. See also Tim Peters' introduction to the \"Algorithms\" " "chapter in the second edition of *Python Cookbook*, published by O'Reilly." msgstr "" +"該模組提供了一種對少量 Python 程式碼進行計時的簡單方法。它有一個\\ :ref:" +"`timeit-command-line-interface`\\ 和一個\\ :ref:`可呼叫介面 `,它避免了許多測量執行時間的常見陷阱。另請參閱由 O'Reilly 出版的 " +"*Python 錦囊妙計 (Python Cookbook)* 第二版中 Tim Peters 所寫的「演算法」章節" +"的介紹。" #: ../../library/timeit.rst:23 msgid "Basic Examples" @@ -45,14 +51,16 @@ msgid "" "The following example shows how the :ref:`timeit-command-line-interface` can " "be used to compare three different expressions:" msgstr "" +"以下範例展示了如何使用\\ :ref:`timeit-command-line-interface`\\ 來比較三個不" +"同的運算式:" #: ../../library/timeit.rst:37 msgid "This can be achieved from the :ref:`python-interface` with::" -msgstr "" +msgstr "這可以透過 :ref:`python-interface`\\ 來實現: ::" #: ../../library/timeit.rst:47 msgid "A callable can also be passed from the :ref:`python-interface`::" -msgstr "" +msgstr "也可以在 :ref:`python-interface`\\ 傳遞可呼叫物件: ::" #: ../../library/timeit.rst:52 msgid "" @@ -60,14 +68,16 @@ msgid "" "repetitions only when the command-line interface is used. In the :ref:" "`timeit-examples` section you can find more advanced examples." msgstr "" +"但請注意,僅當使用命令列界面時 :func:`.timeit` 才會自動確定重複次數。在\\ :" +"ref:`timeit-examples`\\ 章節中有更進階的範例。" #: ../../library/timeit.rst:60 msgid "Python Interface" -msgstr "" +msgstr "Python 介面" #: ../../library/timeit.rst:62 msgid "The module defines three convenience functions and a public class:" -msgstr "" +msgstr "該模組定義了三個便利函式和一個公開類別:" #: ../../library/timeit.rst:67 msgid "" @@ -76,6 +86,9 @@ msgid "" "executions. The optional *globals* argument specifies a namespace in which " "to execute the code." msgstr "" +"使用給定的陳述式、*setup* 程式碼和 *timer* 函式建立一個 :class:`Timer` 實例," +"並執行其 :meth:`.timeit` 方法 *number* 次。可選的 *globals* 引數指定會在其中" +"執行程式碼的命名空間。" #: ../../library/timeit.rst:72 ../../library/timeit.rst:83 #: ../../library/timeit.rst:122 @@ -89,24 +102,29 @@ msgid "" "count and *number* executions. The optional *globals* argument specifies a " "namespace in which to execute the code." msgstr "" +"使用給定的陳述式、*setup* 程式碼和 *timer* 函式建立一個 :class:`Timer` 實例," +"並使用給定的 *repeat* 計數和 *number* 來運行其 :meth:`.repeat` 方法。可選的 " +"*globals* 引數指定會在其中執行程式碼的命名空間。" #: ../../library/timeit.rst:86 ../../library/timeit.rst:183 msgid "Default value of *repeat* changed from 3 to 5." -msgstr "" +msgstr "*repeat* 的預設值從 3 更改為 5。" #: ../../library/timeit.rst:92 msgid "" "The default timer, which is always time.perf_counter(), returns float " "seconds. An alternative, time.perf_counter_ns, returns integer nanoseconds." msgstr "" +"預設計時器始終為 time.perf_counter(),會回傳浮點秒數。另一種方法是 time." +"perf_counter_ns,會回傳整數奈秒。" #: ../../library/timeit.rst:95 msgid ":func:`time.perf_counter` is now the default timer." -msgstr "" +msgstr ":func:`time.perf_counter` 現在是預設計時器。" #: ../../library/timeit.rst:101 msgid "Class for timing execution speed of small code snippets." -msgstr "" +msgstr "用於計時小程式碼片段執行速度的類別。" #: ../../library/timeit.rst:103 msgid "" @@ -118,6 +136,11 @@ msgid "" "will by default be executed within timeit's namespace; this behavior can be " "controlled by passing a namespace to *globals*." msgstr "" +"建構函式接受一個要計時的陳述式、一個用於設定的附加陳述式和一個計時器函式。兩" +"個陳述式都預設為 ``'pass'``;計時器函式會與平台相依(請參閱模組文件字串 (doc " +"string))。*stmt* 和 *setup* 還可以包含由 ``;`` 或換行符號分隔的多個陳述式," +"只要它們不包含多行字串文字即可。預設情況下,該陳述式將在 timeit 的命名空間內" +"執行;可以透過將命名空間傳遞給 *globals* 來控制此行為。" #: ../../library/timeit.rst:111 msgid "" @@ -125,12 +148,14 @@ msgid "" "timeit` method. The :meth:`.repeat` and :meth:`.autorange` methods are " "convenience methods to call :meth:`.timeit` multiple times." msgstr "" +"要測量第一個陳述式的執行時間,請使用 :meth:`.timeit` 方法。:meth:`.repeat` " +"和 :meth:`.autorange` 方法是多次呼叫 :meth:`.timeit` 的便捷方法。" #: ../../library/timeit.rst:115 msgid "" "The execution time of *setup* is excluded from the overall timed execution " "run." -msgstr "" +msgstr "*setup* 的執行時間不包含在總體運行計時中。" #: ../../library/timeit.rst:117 msgid "" @@ -139,6 +164,9 @@ msgid "" "will then be executed by :meth:`.timeit`. Note that the timing overhead is " "a little larger in this case because of the extra function calls." msgstr "" +"*stmt* 和 *setup* 參數還可以接受無需引數即可呼叫的物件。這會把對它們的呼叫嵌" +"入到計時器函式中,然後由 :meth:`.timeit` 去執行。請注意,在這種情況下,因有額" +"外的函式呼叫,時間開銷 (timing overhead) 會稍大一些。" #: ../../library/timeit.rst:127 msgid "" @@ -149,6 +177,9 @@ msgid "" "million. The main statement, the setup statement and the timer function to " "be used are passed to the constructor." msgstr "" +"主陳述式執行 *number* 次的時間。這將執行一次設定陳述式,然後回傳多次執行主陳" +"述式所需的時間。預設計時器以浮點形式回傳秒數,引數是迴圈的次數,預設為一百萬" +"次。要使用的主陳述式、設定陳述式和計時器函式會被傳遞給建構函式。" #: ../../library/timeit.rst:136 msgid "" @@ -159,10 +190,14 @@ msgid "" "so, GC can be re-enabled as the first statement in the *setup* string. For " "example::" msgstr "" +"預設情況下 :meth:`.timeit` 在計時期間會暫時關閉\\ :term:`垃圾回收 `。這種方法的優點是它使獨立時序更具可比較性,缺點是 GC 可能是被測" +"函式性能的重要組成部分。如果是這樣,可以將 GC 作為 *setup* 字串中的第一個陳述" +"式以重新啟用。例如: ::" #: ../../library/timeit.rst:148 msgid "Automatically determine how many times to call :meth:`.timeit`." -msgstr "" +msgstr "自動決定呼叫 :meth:`.timeit` 次數。" #: ../../library/timeit.rst:150 msgid "" @@ -172,16 +207,21 @@ msgid "" "numbers from the sequence 1, 2, 5, 10, 20, 50, ... until the time taken is " "at least 0.2 second." msgstr "" +"這是一個便捷函式,它重複呼叫 :meth:`.timeit` 以使得總時間 >= 0.2 秒,再回傳最" +"終結果(迴圈數、該迴圈數所花費的時間)。它以 1、2、5、10、20、50... 的順序遞" +"增數字來呼叫 :meth:`.timeit` 直到所用時間至少為 0.2 秒。" #: ../../library/timeit.rst:156 msgid "" "If *callback* is given and is not ``None``, it will be called after each " "trial with two arguments: ``callback(number, time_taken)``." msgstr "" +"如果有給定 *callback* 且不是 ``None``,則每次試驗後都會使用兩個引數來呼叫它:" +"``callback(number, time_taken)``。" #: ../../library/timeit.rst:164 msgid "Call :meth:`.timeit` a few times." -msgstr "" +msgstr "呼叫 :meth:`.timeit` 數次。" #: ../../library/timeit.rst:166 msgid "" @@ -190,6 +230,9 @@ msgid "" "call :meth:`.timeit`. The second argument specifies the *number* argument " "for :meth:`.timeit`." msgstr "" +"這是一個方便的函式,它會重複呼叫 :meth:`.timeit` 並回傳結果列表。第一個引數指" +"定呼叫 :meth:`.timeit` 的次數,第二個引數指定 :meth:`.timeit` 的 *number* 引" +"數。" #: ../../library/timeit.rst:173 msgid "" @@ -202,14 +245,19 @@ msgid "" "only number you should be interested in. After that, you should look at the " "entire vector and apply common sense rather than statistics." msgstr "" +"人們很容易根據結果向量來計算出平均值和標準差並將其作為依歸,然而這並不是很有" +"用。在典型情況下,最低值給出了機器運行給定程式碼片段的速度的下限;結果向量中" +"較高的值通常不是由 Python 速度的變化所引起,而是由干擾計時精度的其他行程造成" +"的。因此,結果中的 :func:`min` 可能是你應該感興趣的唯一數字。在解讀該數據後," +"你應該查看整個向量並以常識判讀而非單純仰賴統計資訊。" #: ../../library/timeit.rst:189 msgid "Helper to print a traceback from the timed code." -msgstr "" +msgstr "從計時程式碼印出回溯 (traceback) 的輔助函式。" #: ../../library/timeit.rst:191 msgid "Typical use::" -msgstr "" +msgstr "典型用法: ::" #: ../../library/timeit.rst:199 msgid "" @@ -217,51 +265,56 @@ msgid "" "compiled template will be displayed. The optional *file* argument directs " "where the traceback is sent; it defaults to :data:`sys.stderr`." msgstr "" +"相對於標準回溯的優點是,已編譯模板中的原始程式碼會被顯示出來。可選的 *file* " +"引數指定回溯的發送位置;它預設為 :data:`sys.stderr`。" #: ../../library/timeit.rst:207 msgid "Command-Line Interface" -msgstr "命令執行列介面" +msgstr "命令列介面" #: ../../library/timeit.rst:209 msgid "" "When called as a program from the command line, the following form is used::" -msgstr "" +msgstr "當從命令列作為程式呼叫時,請使用以下形式: ::" #: ../../library/timeit.rst:213 msgid "Where the following options are understood:" -msgstr "" +msgstr "其中之以下選項:" #: ../../library/timeit.rst:219 msgid "how many times to execute 'statement'" -msgstr "" +msgstr "執行 'statement' 多少次" #: ../../library/timeit.rst:223 msgid "how many times to repeat the timer (default 5)" -msgstr "" +msgstr "計時器重複多少次(預設 5)" #: ../../library/timeit.rst:227 msgid "statement to be executed once initially (default ``pass``)" -msgstr "" +msgstr "會在一開始執行一次的陳述式(預設為 ``pass``)" #: ../../library/timeit.rst:231 msgid "" "measure process time, not wallclock time, using :func:`time.process_time` " "instead of :func:`time.perf_counter`, which is the default" msgstr "" +"若要測量行程時間 (process time) 而非掛鐘時間 (wallclock time),請使用 :func:" +"`time.process_time` 而不是預設的 :func:`time.perf_counter`" #: ../../library/timeit.rst:238 msgid "" "specify a time unit for timer output; can select ``nsec``, ``usec``, " "``msec``, or ``sec``" msgstr "" +"指定定時器輸出的時間單位;可以選擇 ``nsec``、``usec``、``msec`` 或 ``sec``" #: ../../library/timeit.rst:244 msgid "print raw timing results; repeat for more digits precision" -msgstr "" +msgstr "印出原始計時結果;重複執行以獲得更高的數字精度" #: ../../library/timeit.rst:248 msgid "print a short usage message and exit" -msgstr "" +msgstr "印出一條簡短的使用訊息並退出" #: ../../library/timeit.rst:250 msgid "" @@ -270,6 +323,9 @@ msgid "" "quotes and using leading spaces. Multiple :option:`-s` options are treated " "similarly." msgstr "" +"可以透過將每一列陳述式指定為單獨引數來給定多列陳述式;可透過將引數括在引號中" +"並使用前導空格以實現縮進列 (indented lines)。多個 :option:`-s` 選項的作用類" +"似。" #: ../../library/timeit.rst:255 msgid "" @@ -277,6 +333,8 @@ msgid "" "trying increasing numbers from the sequence 1, 2, 5, 10, 20, 50, ... until " "the total time is at least 0.2 seconds." msgstr "" +"如果沒有給定 :option:`-n`,則透過嘗試從序列 1, 2, 5, 10, 20, 50, ... 中增加數" +"字來計算合適的迴圈次數,直到總時間至少為 0.2 秒。" #: ../../library/timeit.rst:259 msgid "" @@ -287,6 +345,10 @@ msgid "" "probably enough in most cases. You can use :func:`time.process_time` to " "measure CPU time." msgstr "" +":func:`default_timer` 測量可能會受到同一台機器上運行的其他程式的影響,因此," +"當需要精確計時時,最好的做法是重複計時幾次並使用最佳時間。:option:`-r` 選項對" +"此很有用;在大多數情況下,預設的重複 5 次可能就足夠了。你可以使用 :func:" +"`time.process_time` 來測量 CPU 時間。" #: ../../library/timeit.rst:267 msgid "" @@ -295,6 +357,9 @@ msgid "" "it. The baseline overhead can be measured by invoking the program without " "arguments, and it might differ between Python versions." msgstr "" +"執行 pass 陳述式會產生一定的基本開銷。這裡的程式碼並不試圖隱藏它,但你應該意" +"識到它的存在。可以透過不帶引數呼叫程式來測量這個基本開銷,且不同 Python 版本" +"之間的基本開銷可能有所不同。" #: ../../library/timeit.rst:276 msgid "Examples" @@ -304,7 +369,7 @@ msgstr "範例" msgid "" "It is possible to provide a setup statement that is executed only once at " "the beginning:" -msgstr "" +msgstr "可以提供一個僅會在開始時執行一次的設定陳述式:" #: ../../library/timeit.rst:287 msgid "" @@ -315,10 +380,14 @@ msgid "" "within the best repetition of the timing loop. That is, the time the fastest " "repetition took divided by the loop count." msgstr "" +"輸出中包含三個欄位。迴圈計數,它告訴你每次計時迴圈內重複運行陳述式主體的次" +"數。重複計數(「最好的 5 次」)告訴你計時迴圈重複了多少次。以及最後陳述式主體" +"在計時迴圈的最佳的幾次重複執行內平均花費的時間。也就是說,最快的幾次重複執行" +"所花費的總時間除以迴圈計數。" #: ../../library/timeit.rst:302 msgid "The same can be done using the :class:`Timer` class and its methods::" -msgstr "" +msgstr "同樣可以使用 :class:`Timer` 類別及其方法來完成: ::" #: ../../library/timeit.rst:312 msgid "" @@ -326,12 +395,17 @@ msgid "" "lines. Here we compare the cost of using :func:`hasattr` vs. :keyword:`try`/:" "keyword:`except` to test for missing and present object attributes:" msgstr "" +"以下範例展示如何對包含多行的運算式進行計時。這裡我們使用 :func:`hasattr` 與 :" +"keyword:`try`/:keyword:`except` 來測試缺失和存在之物件屬性並比較其花費 " +"(cost):" #: ../../library/timeit.rst:358 msgid "" "To give the :mod:`timeit` module access to functions you define, you can " "pass a *setup* parameter which contains an import statement::" msgstr "" +"要讓 :mod:`timeit` 模組存取你定義的函式,你可以傳遞一個包含 import 陳述式的 " +"*setup* 參數: ::" #: ../../library/timeit.rst:369 msgid "" @@ -339,11 +413,13 @@ msgid "" "will cause the code to be executed within your current global namespace. " "This can be more convenient than individually specifying imports::" msgstr "" +"另一種選擇是將 :func:`globals` 傳遞給 *globals* 參數,這將導致程式碼在當前的" +"全域命名空間中執行,這比單獨指定 import 更方便: ::" #: ../../library/timeit.rst:9 msgid "Benchmarking" -msgstr "" +msgstr "基準量測 (Benchmarking)" #: ../../library/timeit.rst:9 msgid "Performance" -msgstr "" +msgstr "性能表現"