Skip to content

Commit 6309010

Browse files
authored
Translate library/timeit.po (#650)
* feat: translate `library/timeit.po` * chore: update based on review comments
1 parent 5ee5eee commit 6309010

File tree

1 file changed

+103
-27
lines changed

1 file changed

+103
-27
lines changed

library/timeit.po

Lines changed: 103 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
# SOME DESCRIPTIVE TITLE.
2-
# Copyright (C) 2001-2022, Python Software Foundation
1+
# Copyright (C) 2001-2023, Python Software Foundation
32
# This file is distributed under the same license as the Python package.
43
#
54
# Translators:
5+
# Adrian Liaw <[email protected]>, 2018
6+
# Matt Wang <[email protected]>, 2023
67
msgid ""
78
msgstr ""
89
"Project-Id-Version: Python 3.12\n"
910
"Report-Msgid-Bugs-To: \n"
1011
"POT-Creation-Date: 2023-08-27 18:15+0000\n"
1112
"PO-Revision-Date: 2023-05-20 13:21+0800\n"
12-
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
13+
"Last-Translator: Matt Wang <mattwang44@gmail.com>\n"
1314
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1415
"tw)\n"
1516
"Language: zh_TW\n"
@@ -35,6 +36,11 @@ msgid ""
3536
"execution times. See also Tim Peters' introduction to the \"Algorithms\" "
3637
"chapter in the second edition of *Python Cookbook*, published by O'Reilly."
3738
msgstr ""
39+
"該模組提供了一種對少量 Python 程式碼進行計時的簡單方法。它有一個\\ :ref:"
40+
"`timeit-command-line-interface`\\ 和一個\\ :ref:`可呼叫介面 <python-"
41+
"interface>`,它避免了許多測量執行時間的常見陷阱。另請參閱由 O'Reilly 出版的 "
42+
"*Python 錦囊妙計 (Python Cookbook)* 第二版中 Tim Peters 所寫的「演算法」章節"
43+
"的介紹。"
3844

3945
#: ../../library/timeit.rst:23
4046
msgid "Basic Examples"
@@ -45,29 +51,33 @@ msgid ""
4551
"The following example shows how the :ref:`timeit-command-line-interface` can "
4652
"be used to compare three different expressions:"
4753
msgstr ""
54+
"以下範例展示了如何使用\\ :ref:`timeit-command-line-interface`\\ 來比較三個不"
55+
"同的運算式:"
4856

4957
#: ../../library/timeit.rst:37
5058
msgid "This can be achieved from the :ref:`python-interface` with::"
51-
msgstr ""
59+
msgstr "這可以透過 :ref:`python-interface`\\ 來實現: ::"
5260

5361
#: ../../library/timeit.rst:47
5462
msgid "A callable can also be passed from the :ref:`python-interface`::"
55-
msgstr ""
63+
msgstr "也可以在 :ref:`python-interface`\\ 傳遞可呼叫物件: ::"
5664

5765
#: ../../library/timeit.rst:52
5866
msgid ""
5967
"Note however that :func:`.timeit` will automatically determine the number of "
6068
"repetitions only when the command-line interface is used. In the :ref:"
6169
"`timeit-examples` section you can find more advanced examples."
6270
msgstr ""
71+
"但請注意,僅當使用命令列界面時 :func:`.timeit` 才會自動確定重複次數。在\\ :"
72+
"ref:`timeit-examples`\\ 章節中有更進階的範例。"
6373

6474
#: ../../library/timeit.rst:60
6575
msgid "Python Interface"
66-
msgstr ""
76+
msgstr "Python 介面"
6777

6878
#: ../../library/timeit.rst:62
6979
msgid "The module defines three convenience functions and a public class:"
70-
msgstr ""
80+
msgstr "該模組定義了三個便利函式和一個公開類別:"
7181

7282
#: ../../library/timeit.rst:67
7383
msgid ""
@@ -76,6 +86,9 @@ msgid ""
7686
"executions. The optional *globals* argument specifies a namespace in which "
7787
"to execute the code."
7888
msgstr ""
89+
"使用給定的陳述式、*setup* 程式碼和 *timer* 函式建立一個 :class:`Timer` 實例,"
90+
"並執行其 :meth:`.timeit` 方法 *number* 次。可選的 *globals* 引數指定會在其中"
91+
"執行程式碼的命名空間。"
7992

8093
#: ../../library/timeit.rst:72 ../../library/timeit.rst:83
8194
#: ../../library/timeit.rst:122
@@ -89,24 +102,29 @@ msgid ""
89102
"count and *number* executions. The optional *globals* argument specifies a "
90103
"namespace in which to execute the code."
91104
msgstr ""
105+
"使用給定的陳述式、*setup* 程式碼和 *timer* 函式建立一個 :class:`Timer` 實例,"
106+
"並使用給定的 *repeat* 計數和 *number* 來運行其 :meth:`.repeat` 方法。可選的 "
107+
"*globals* 引數指定會在其中執行程式碼的命名空間。"
92108

93109
#: ../../library/timeit.rst:86 ../../library/timeit.rst:183
94110
msgid "Default value of *repeat* changed from 3 to 5."
95-
msgstr ""
111+
msgstr "*repeat* 的預設值從 3 更改為 5。"
96112

97113
#: ../../library/timeit.rst:92
98114
msgid ""
99115
"The default timer, which is always time.perf_counter(), returns float "
100116
"seconds. An alternative, time.perf_counter_ns, returns integer nanoseconds."
101117
msgstr ""
118+
"預設計時器始終為 time.perf_counter(),會回傳浮點秒數。另一種方法是 time."
119+
"perf_counter_ns,會回傳整數奈秒。"
102120

103121
#: ../../library/timeit.rst:95
104122
msgid ":func:`time.perf_counter` is now the default timer."
105-
msgstr ""
123+
msgstr ":func:`time.perf_counter` 現在是預設計時器。"
106124

107125
#: ../../library/timeit.rst:101
108126
msgid "Class for timing execution speed of small code snippets."
109-
msgstr ""
127+
msgstr "用於計時小程式碼片段執行速度的類別。"
110128

111129
#: ../../library/timeit.rst:103
112130
msgid ""
@@ -118,19 +136,26 @@ msgid ""
118136
"will by default be executed within timeit's namespace; this behavior can be "
119137
"controlled by passing a namespace to *globals*."
120138
msgstr ""
139+
"建構函式接受一個要計時的陳述式、一個用於設定的附加陳述式和一個計時器函式。兩"
140+
"個陳述式都預設為 ``'pass'``;計時器函式會與平台相依(請參閱模組文件字串 (doc "
141+
"string))。*stmt* 和 *setup* 還可以包含由 ``;`` 或換行符號分隔的多個陳述式,"
142+
"只要它們不包含多行字串文字即可。預設情況下,該陳述式將在 timeit 的命名空間內"
143+
"執行;可以透過將命名空間傳遞給 *globals* 來控制此行為。"
121144

122145
#: ../../library/timeit.rst:111
123146
msgid ""
124147
"To measure the execution time of the first statement, use the :meth:`."
125148
"timeit` method. The :meth:`.repeat` and :meth:`.autorange` methods are "
126149
"convenience methods to call :meth:`.timeit` multiple times."
127150
msgstr ""
151+
"要測量第一個陳述式的執行時間,請使用 :meth:`.timeit` 方法。:meth:`.repeat` "
152+
"和 :meth:`.autorange` 方法是多次呼叫 :meth:`.timeit` 的便捷方法。"
128153

129154
#: ../../library/timeit.rst:115
130155
msgid ""
131156
"The execution time of *setup* is excluded from the overall timed execution "
132157
"run."
133-
msgstr ""
158+
msgstr "*setup* 的執行時間不包含在總體運行計時中。"
134159

135160
#: ../../library/timeit.rst:117
136161
msgid ""
@@ -139,6 +164,9 @@ msgid ""
139164
"will then be executed by :meth:`.timeit`. Note that the timing overhead is "
140165
"a little larger in this case because of the extra function calls."
141166
msgstr ""
167+
"*stmt* 和 *setup* 參數還可以接受無需引數即可呼叫的物件。這會把對它們的呼叫嵌"
168+
"入到計時器函式中,然後由 :meth:`.timeit` 去執行。請注意,在這種情況下,因有額"
169+
"外的函式呼叫,時間開銷 (timing overhead) 會稍大一些。"
142170

143171
#: ../../library/timeit.rst:127
144172
msgid ""
@@ -149,6 +177,9 @@ msgid ""
149177
"million. The main statement, the setup statement and the timer function to "
150178
"be used are passed to the constructor."
151179
msgstr ""
180+
"主陳述式執行 *number* 次的時間。這將執行一次設定陳述式,然後回傳多次執行主陳"
181+
"述式所需的時間。預設計時器以浮點形式回傳秒數,引數是迴圈的次數,預設為一百萬"
182+
"次。要使用的主陳述式、設定陳述式和計時器函式會被傳遞給建構函式。"
152183

153184
#: ../../library/timeit.rst:136
154185
msgid ""
@@ -159,10 +190,14 @@ msgid ""
159190
"so, GC can be re-enabled as the first statement in the *setup* string. For "
160191
"example::"
161192
msgstr ""
193+
"預設情況下 :meth:`.timeit` 在計時期間會暫時關閉\\ :term:`垃圾回收 <garbage "
194+
"collection>`。這種方法的優點是它使獨立時序更具可比較性,缺點是 GC 可能是被測"
195+
"函式性能的重要組成部分。如果是這樣,可以將 GC 作為 *setup* 字串中的第一個陳述"
196+
"式以重新啟用。例如: ::"
162197

163198
#: ../../library/timeit.rst:148
164199
msgid "Automatically determine how many times to call :meth:`.timeit`."
165-
msgstr ""
200+
msgstr "自動決定呼叫 :meth:`.timeit` 次數。"
166201

167202
#: ../../library/timeit.rst:150
168203
msgid ""
@@ -172,16 +207,21 @@ msgid ""
172207
"numbers from the sequence 1, 2, 5, 10, 20, 50, ... until the time taken is "
173208
"at least 0.2 second."
174209
msgstr ""
210+
"這是一個便捷函式,它重複呼叫 :meth:`.timeit` 以使得總時間 >= 0.2 秒,再回傳最"
211+
"終結果(迴圈數、該迴圈數所花費的時間)。它以 1、2、5、10、20、50... 的順序遞"
212+
"增數字來呼叫 :meth:`.timeit` 直到所用時間至少為 0.2 秒。"
175213

176214
#: ../../library/timeit.rst:156
177215
msgid ""
178216
"If *callback* is given and is not ``None``, it will be called after each "
179217
"trial with two arguments: ``callback(number, time_taken)``."
180218
msgstr ""
219+
"如果有給定 *callback* 且不是 ``None``,則每次試驗後都會使用兩個引數來呼叫它:"
220+
"``callback(number, time_taken)``。"
181221

182222
#: ../../library/timeit.rst:164
183223
msgid "Call :meth:`.timeit` a few times."
184-
msgstr ""
224+
msgstr "呼叫 :meth:`.timeit` 數次。"
185225

186226
#: ../../library/timeit.rst:166
187227
msgid ""
@@ -190,6 +230,9 @@ msgid ""
190230
"call :meth:`.timeit`. The second argument specifies the *number* argument "
191231
"for :meth:`.timeit`."
192232
msgstr ""
233+
"這是一個方便的函式,它會重複呼叫 :meth:`.timeit` 並回傳結果列表。第一個引數指"
234+
"定呼叫 :meth:`.timeit` 的次數,第二個引數指定 :meth:`.timeit` 的 *number* 引"
235+
"數。"
193236

194237
#: ../../library/timeit.rst:173
195238
msgid ""
@@ -202,66 +245,76 @@ msgid ""
202245
"only number you should be interested in. After that, you should look at the "
203246
"entire vector and apply common sense rather than statistics."
204247
msgstr ""
248+
"人們很容易根據結果向量來計算出平均值和標準差並將其作為依歸,然而這並不是很有"
249+
"用。在典型情況下,最低值給出了機器運行給定程式碼片段的速度的下限;結果向量中"
250+
"較高的值通常不是由 Python 速度的變化所引起,而是由干擾計時精度的其他行程造成"
251+
"的。因此,結果中的 :func:`min` 可能是你應該感興趣的唯一數字。在解讀該數據後,"
252+
"你應該查看整個向量並以常識判讀而非單純仰賴統計資訊。"
205253

206254
#: ../../library/timeit.rst:189
207255
msgid "Helper to print a traceback from the timed code."
208-
msgstr ""
256+
msgstr "從計時程式碼印出回溯 (traceback) 的輔助函式。"
209257

210258
#: ../../library/timeit.rst:191
211259
msgid "Typical use::"
212-
msgstr ""
260+
msgstr "典型用法: ::"
213261

214262
#: ../../library/timeit.rst:199
215263
msgid ""
216264
"The advantage over the standard traceback is that source lines in the "
217265
"compiled template will be displayed. The optional *file* argument directs "
218266
"where the traceback is sent; it defaults to :data:`sys.stderr`."
219267
msgstr ""
268+
"相對於標準回溯的優點是,已編譯模板中的原始程式碼會被顯示出來。可選的 *file* "
269+
"引數指定回溯的發送位置;它預設為 :data:`sys.stderr`。"
220270

221271
#: ../../library/timeit.rst:207
222272
msgid "Command-Line Interface"
223-
msgstr "命令執行列介面"
273+
msgstr "命令列介面"
224274

225275
#: ../../library/timeit.rst:209
226276
msgid ""
227277
"When called as a program from the command line, the following form is used::"
228-
msgstr ""
278+
msgstr "當從命令列作為程式呼叫時,請使用以下形式: ::"
229279

230280
#: ../../library/timeit.rst:213
231281
msgid "Where the following options are understood:"
232-
msgstr ""
282+
msgstr "其中之以下選項:"
233283

234284
#: ../../library/timeit.rst:219
235285
msgid "how many times to execute 'statement'"
236-
msgstr ""
286+
msgstr "執行 'statement' 多少次"
237287

238288
#: ../../library/timeit.rst:223
239289
msgid "how many times to repeat the timer (default 5)"
240-
msgstr ""
290+
msgstr "計時器重複多少次(預設 5)"
241291

242292
#: ../../library/timeit.rst:227
243293
msgid "statement to be executed once initially (default ``pass``)"
244-
msgstr ""
294+
msgstr "會在一開始執行一次的陳述式(預設為 ``pass``)"
245295

246296
#: ../../library/timeit.rst:231
247297
msgid ""
248298
"measure process time, not wallclock time, using :func:`time.process_time` "
249299
"instead of :func:`time.perf_counter`, which is the default"
250300
msgstr ""
301+
"若要測量行程時間 (process time) 而非掛鐘時間 (wallclock time),請使用 :func:"
302+
"`time.process_time` 而不是預設的 :func:`time.perf_counter`"
251303

252304
#: ../../library/timeit.rst:238
253305
msgid ""
254306
"specify a time unit for timer output; can select ``nsec``, ``usec``, "
255307
"``msec``, or ``sec``"
256308
msgstr ""
309+
"指定定時器輸出的時間單位;可以選擇 ``nsec``、``usec``、``msec`` 或 ``sec``"
257310

258311
#: ../../library/timeit.rst:244
259312
msgid "print raw timing results; repeat for more digits precision"
260-
msgstr ""
313+
msgstr "印出原始計時結果;重複執行以獲得更高的數字精度"
261314

262315
#: ../../library/timeit.rst:248
263316
msgid "print a short usage message and exit"
264-
msgstr ""
317+
msgstr "印出一條簡短的使用訊息並退出"
265318

266319
#: ../../library/timeit.rst:250
267320
msgid ""
@@ -270,13 +323,18 @@ msgid ""
270323
"quotes and using leading spaces. Multiple :option:`-s` options are treated "
271324
"similarly."
272325
msgstr ""
326+
"可以透過將每一列陳述式指定為單獨引數來給定多列陳述式;可透過將引數括在引號中"
327+
"並使用前導空格以實現縮進列 (indented lines)。多個 :option:`-s` 選項的作用類"
328+
"似。"
273329

274330
#: ../../library/timeit.rst:255
275331
msgid ""
276332
"If :option:`-n` is not given, a suitable number of loops is calculated by "
277333
"trying increasing numbers from the sequence 1, 2, 5, 10, 20, 50, ... until "
278334
"the total time is at least 0.2 seconds."
279335
msgstr ""
336+
"如果沒有給定 :option:`-n`,則透過嘗試從序列 1, 2, 5, 10, 20, 50, ... 中增加數"
337+
"字來計算合適的迴圈次數,直到總時間至少為 0.2 秒。"
280338

281339
#: ../../library/timeit.rst:259
282340
msgid ""
@@ -287,6 +345,10 @@ msgid ""
287345
"probably enough in most cases. You can use :func:`time.process_time` to "
288346
"measure CPU time."
289347
msgstr ""
348+
":func:`default_timer` 測量可能會受到同一台機器上運行的其他程式的影響,因此,"
349+
"當需要精確計時時,最好的做法是重複計時幾次並使用最佳時間。:option:`-r` 選項對"
350+
"此很有用;在大多數情況下,預設的重複 5 次可能就足夠了。你可以使用 :func:"
351+
"`time.process_time` 來測量 CPU 時間。"
290352

291353
#: ../../library/timeit.rst:267
292354
msgid ""
@@ -295,6 +357,9 @@ msgid ""
295357
"it. The baseline overhead can be measured by invoking the program without "
296358
"arguments, and it might differ between Python versions."
297359
msgstr ""
360+
"執行 pass 陳述式會產生一定的基本開銷。這裡的程式碼並不試圖隱藏它,但你應該意"
361+
"識到它的存在。可以透過不帶引數呼叫程式來測量這個基本開銷,且不同 Python 版本"
362+
"之間的基本開銷可能有所不同。"
298363

299364
#: ../../library/timeit.rst:276
300365
msgid "Examples"
@@ -304,7 +369,7 @@ msgstr "範例"
304369
msgid ""
305370
"It is possible to provide a setup statement that is executed only once at "
306371
"the beginning:"
307-
msgstr ""
372+
msgstr "可以提供一個僅會在開始時執行一次的設定陳述式:"
308373

309374
#: ../../library/timeit.rst:287
310375
msgid ""
@@ -315,35 +380,46 @@ msgid ""
315380
"within the best repetition of the timing loop. That is, the time the fastest "
316381
"repetition took divided by the loop count."
317382
msgstr ""
383+
"輸出中包含三個欄位。迴圈計數,它告訴你每次計時迴圈內重複運行陳述式主體的次"
384+
"數。重複計數(「最好的 5 次」)告訴你計時迴圈重複了多少次。以及最後陳述式主體"
385+
"在計時迴圈的最佳的幾次重複執行內平均花費的時間。也就是說,最快的幾次重複執行"
386+
"所花費的總時間除以迴圈計數。"
318387

319388
#: ../../library/timeit.rst:302
320389
msgid "The same can be done using the :class:`Timer` class and its methods::"
321-
msgstr ""
390+
msgstr "同樣可以使用 :class:`Timer` 類別及其方法來完成: ::"
322391

323392
#: ../../library/timeit.rst:312
324393
msgid ""
325394
"The following examples show how to time expressions that contain multiple "
326395
"lines. Here we compare the cost of using :func:`hasattr` vs. :keyword:`try`/:"
327396
"keyword:`except` to test for missing and present object attributes:"
328397
msgstr ""
398+
"以下範例展示如何對包含多行的運算式進行計時。這裡我們使用 :func:`hasattr` 與 :"
399+
"keyword:`try`/:keyword:`except` 來測試缺失和存在之物件屬性並比較其花費 "
400+
"(cost):"
329401

330402
#: ../../library/timeit.rst:358
331403
msgid ""
332404
"To give the :mod:`timeit` module access to functions you define, you can "
333405
"pass a *setup* parameter which contains an import statement::"
334406
msgstr ""
407+
"要讓 :mod:`timeit` 模組存取你定義的函式,你可以傳遞一個包含 import 陳述式的 "
408+
"*setup* 參數: ::"
335409

336410
#: ../../library/timeit.rst:369
337411
msgid ""
338412
"Another option is to pass :func:`globals` to the *globals* parameter, which "
339413
"will cause the code to be executed within your current global namespace. "
340414
"This can be more convenient than individually specifying imports::"
341415
msgstr ""
416+
"另一種選擇是將 :func:`globals` 傳遞給 *globals* 參數,這將導致程式碼在當前的"
417+
"全域命名空間中執行,這比單獨指定 import 更方便: ::"
342418

343419
#: ../../library/timeit.rst:9
344420
msgid "Benchmarking"
345-
msgstr ""
421+
msgstr "基準量測 (Benchmarking)"
346422

347423
#: ../../library/timeit.rst:9
348424
msgid "Performance"
349-
msgstr ""
425+
msgstr "性能表現"

0 commit comments

Comments
 (0)