1
- # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) 2001-2022, Python Software Foundation
1
+ # Copyright (C) 2001-2023, Python Software Foundation
3
2
# This file is distributed under the same license as the Python package.
4
3
#
5
4
# Translators:
5
+ # Adrian Liaw <[email protected] >, 2018
6
+ # Matt Wang <[email protected] >, 2023
6
7
msgid ""
7
8
msgstr ""
8
9
"Project-Id-Version : Python 3.12\n "
9
10
"Report-Msgid-Bugs-To : \n "
10
11
"POT-Creation-Date : 2023-08-27 18:15+0000\n "
11
12
"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 "
13
14
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
14
15
"tw)\n "
15
16
"Language : zh_TW\n "
@@ -35,6 +36,11 @@ msgid ""
35
36
"execution times. See also Tim Peters' introduction to the \" Algorithms\" "
36
37
"chapter in the second edition of *Python Cookbook*, published by O'Reilly."
37
38
msgstr ""
39
+ "該模組提供了一種對少量 Python 程式碼進行計時的簡單方法。它有一個\\ :ref:"
40
+ "`timeit-command-line-interface`\\ 和一個\\ :ref:`可呼叫介面 <python-"
41
+ "interface>`,它避免了許多測量執行時間的常見陷阱。另請參閱由 O'Reilly 出版的 "
42
+ "*Python 錦囊妙計 (Python Cookbook)* 第二版中 Tim Peters 所寫的「演算法」章節"
43
+ "的介紹。"
38
44
39
45
#: ../../library/timeit.rst:23
40
46
msgid "Basic Examples"
@@ -45,29 +51,33 @@ msgid ""
45
51
"The following example shows how the :ref:`timeit-command-line-interface` can "
46
52
"be used to compare three different expressions:"
47
53
msgstr ""
54
+ "以下範例展示了如何使用\\ :ref:`timeit-command-line-interface`\\ 來比較三個不"
55
+ "同的運算式:"
48
56
49
57
#: ../../library/timeit.rst:37
50
58
msgid "This can be achieved from the :ref:`python-interface` with::"
51
- msgstr ""
59
+ msgstr "這可以透過 :ref:`python-interface` \\ 來實現: :: "
52
60
53
61
#: ../../library/timeit.rst:47
54
62
msgid "A callable can also be passed from the :ref:`python-interface`::"
55
- msgstr ""
63
+ msgstr "也可以在 :ref:`python-interface` \\ 傳遞可呼叫物件: :: "
56
64
57
65
#: ../../library/timeit.rst:52
58
66
msgid ""
59
67
"Note however that :func:`.timeit` will automatically determine the number of "
60
68
"repetitions only when the command-line interface is used. In the :ref:"
61
69
"`timeit-examples` section you can find more advanced examples."
62
70
msgstr ""
71
+ "但請注意,僅當使用命令列界面時 :func:`.timeit` 才會自動確定重複次數。在\\ :"
72
+ "ref:`timeit-examples`\\ 章節中有更進階的範例。"
63
73
64
74
#: ../../library/timeit.rst:60
65
75
msgid "Python Interface"
66
- msgstr ""
76
+ msgstr "Python 介面 "
67
77
68
78
#: ../../library/timeit.rst:62
69
79
msgid "The module defines three convenience functions and a public class:"
70
- msgstr ""
80
+ msgstr "該模組定義了三個便利函式和一個公開類別: "
71
81
72
82
#: ../../library/timeit.rst:67
73
83
msgid ""
@@ -76,6 +86,9 @@ msgid ""
76
86
"executions. The optional *globals* argument specifies a namespace in which "
77
87
"to execute the code."
78
88
msgstr ""
89
+ "使用給定的陳述式、*setup* 程式碼和 *timer* 函式建立一個 :class:`Timer` 實例,"
90
+ "並執行其 :meth:`.timeit` 方法 *number* 次。可選的 *globals* 引數指定會在其中"
91
+ "執行程式碼的命名空間。"
79
92
80
93
#: ../../library/timeit.rst:72 ../../library/timeit.rst:83
81
94
#: ../../library/timeit.rst:122
@@ -89,24 +102,29 @@ msgid ""
89
102
"count and *number* executions. The optional *globals* argument specifies a "
90
103
"namespace in which to execute the code."
91
104
msgstr ""
105
+ "使用給定的陳述式、*setup* 程式碼和 *timer* 函式建立一個 :class:`Timer` 實例,"
106
+ "並使用給定的 *repeat* 計數和 *number* 來運行其 :meth:`.repeat` 方法。可選的 "
107
+ "*globals* 引數指定會在其中執行程式碼的命名空間。"
92
108
93
109
#: ../../library/timeit.rst:86 ../../library/timeit.rst:183
94
110
msgid "Default value of *repeat* changed from 3 to 5."
95
- msgstr ""
111
+ msgstr "*repeat* 的預設值從 3 更改為 5。 "
96
112
97
113
#: ../../library/timeit.rst:92
98
114
msgid ""
99
115
"The default timer, which is always time.perf_counter(), returns float "
100
116
"seconds. An alternative, time.perf_counter_ns, returns integer nanoseconds."
101
117
msgstr ""
118
+ "預設計時器始終為 time.perf_counter(),會回傳浮點秒數。另一種方法是 time."
119
+ "perf_counter_ns,會回傳整數奈秒。"
102
120
103
121
#: ../../library/timeit.rst:95
104
122
msgid ":func:`time.perf_counter` is now the default timer."
105
- msgstr ""
123
+ msgstr ":func:`time.perf_counter` 現在是預設計時器。 "
106
124
107
125
#: ../../library/timeit.rst:101
108
126
msgid "Class for timing execution speed of small code snippets."
109
- msgstr ""
127
+ msgstr "用於計時小程式碼片段執行速度的類別。 "
110
128
111
129
#: ../../library/timeit.rst:103
112
130
msgid ""
@@ -118,19 +136,26 @@ msgid ""
118
136
"will by default be executed within timeit's namespace; this behavior can be "
119
137
"controlled by passing a namespace to *globals*."
120
138
msgstr ""
139
+ "建構函式接受一個要計時的陳述式、一個用於設定的附加陳述式和一個計時器函式。兩"
140
+ "個陳述式都預設為 ``'pass'``;計時器函式會與平台相依(請參閱模組文件字串 (doc "
141
+ "string))。*stmt* 和 *setup* 還可以包含由 ``;`` 或換行符號分隔的多個陳述式,"
142
+ "只要它們不包含多行字串文字即可。預設情況下,該陳述式將在 timeit 的命名空間內"
143
+ "執行;可以透過將命名空間傳遞給 *globals* 來控制此行為。"
121
144
122
145
#: ../../library/timeit.rst:111
123
146
msgid ""
124
147
"To measure the execution time of the first statement, use the :meth:`."
125
148
"timeit` method. The :meth:`.repeat` and :meth:`.autorange` methods are "
126
149
"convenience methods to call :meth:`.timeit` multiple times."
127
150
msgstr ""
151
+ "要測量第一個陳述式的執行時間,請使用 :meth:`.timeit` 方法。:meth:`.repeat` "
152
+ "和 :meth:`.autorange` 方法是多次呼叫 :meth:`.timeit` 的便捷方法。"
128
153
129
154
#: ../../library/timeit.rst:115
130
155
msgid ""
131
156
"The execution time of *setup* is excluded from the overall timed execution "
132
157
"run."
133
- msgstr ""
158
+ msgstr "*setup* 的執行時間不包含在總體運行計時中。 "
134
159
135
160
#: ../../library/timeit.rst:117
136
161
msgid ""
@@ -139,6 +164,9 @@ msgid ""
139
164
"will then be executed by :meth:`.timeit`. Note that the timing overhead is "
140
165
"a little larger in this case because of the extra function calls."
141
166
msgstr ""
167
+ "*stmt* 和 *setup* 參數還可以接受無需引數即可呼叫的物件。這會把對它們的呼叫嵌"
168
+ "入到計時器函式中,然後由 :meth:`.timeit` 去執行。請注意,在這種情況下,因有額"
169
+ "外的函式呼叫,時間開銷 (timing overhead) 會稍大一些。"
142
170
143
171
#: ../../library/timeit.rst:127
144
172
msgid ""
@@ -149,6 +177,9 @@ msgid ""
149
177
"million. The main statement, the setup statement and the timer function to "
150
178
"be used are passed to the constructor."
151
179
msgstr ""
180
+ "主陳述式執行 *number* 次的時間。這將執行一次設定陳述式,然後回傳多次執行主陳"
181
+ "述式所需的時間。預設計時器以浮點形式回傳秒數,引數是迴圈的次數,預設為一百萬"
182
+ "次。要使用的主陳述式、設定陳述式和計時器函式會被傳遞給建構函式。"
152
183
153
184
#: ../../library/timeit.rst:136
154
185
msgid ""
@@ -159,10 +190,14 @@ msgid ""
159
190
"so, GC can be re-enabled as the first statement in the *setup* string. For "
160
191
"example::"
161
192
msgstr ""
193
+ "預設情況下 :meth:`.timeit` 在計時期間會暫時關閉\\ :term:`垃圾回收 <garbage "
194
+ "collection>`。這種方法的優點是它使獨立時序更具可比較性,缺點是 GC 可能是被測"
195
+ "函式性能的重要組成部分。如果是這樣,可以將 GC 作為 *setup* 字串中的第一個陳述"
196
+ "式以重新啟用。例如: ::"
162
197
163
198
#: ../../library/timeit.rst:148
164
199
msgid "Automatically determine how many times to call :meth:`.timeit`."
165
- msgstr ""
200
+ msgstr "自動決定呼叫 :meth:`.timeit` 次數。 "
166
201
167
202
#: ../../library/timeit.rst:150
168
203
msgid ""
@@ -172,16 +207,21 @@ msgid ""
172
207
"numbers from the sequence 1, 2, 5, 10, 20, 50, ... until the time taken is "
173
208
"at least 0.2 second."
174
209
msgstr ""
210
+ "這是一個便捷函式,它重複呼叫 :meth:`.timeit` 以使得總時間 >= 0.2 秒,再回傳最"
211
+ "終結果(迴圈數、該迴圈數所花費的時間)。它以 1、2、5、10、20、50... 的順序遞"
212
+ "增數字來呼叫 :meth:`.timeit` 直到所用時間至少為 0.2 秒。"
175
213
176
214
#: ../../library/timeit.rst:156
177
215
msgid ""
178
216
"If *callback* is given and is not ``None``, it will be called after each "
179
217
"trial with two arguments: ``callback(number, time_taken)``."
180
218
msgstr ""
219
+ "如果有給定 *callback* 且不是 ``None``,則每次試驗後都會使用兩個引數來呼叫它:"
220
+ "``callback(number, time_taken)``。"
181
221
182
222
#: ../../library/timeit.rst:164
183
223
msgid "Call :meth:`.timeit` a few times."
184
- msgstr ""
224
+ msgstr "呼叫 :meth:`.timeit` 數次。 "
185
225
186
226
#: ../../library/timeit.rst:166
187
227
msgid ""
@@ -190,6 +230,9 @@ msgid ""
190
230
"call :meth:`.timeit`. The second argument specifies the *number* argument "
191
231
"for :meth:`.timeit`."
192
232
msgstr ""
233
+ "這是一個方便的函式,它會重複呼叫 :meth:`.timeit` 並回傳結果列表。第一個引數指"
234
+ "定呼叫 :meth:`.timeit` 的次數,第二個引數指定 :meth:`.timeit` 的 *number* 引"
235
+ "數。"
193
236
194
237
#: ../../library/timeit.rst:173
195
238
msgid ""
@@ -202,66 +245,76 @@ msgid ""
202
245
"only number you should be interested in. After that, you should look at the "
203
246
"entire vector and apply common sense rather than statistics."
204
247
msgstr ""
248
+ "人們很容易根據結果向量來計算出平均值和標準差並將其作為依歸,然而這並不是很有"
249
+ "用。在典型情況下,最低值給出了機器運行給定程式碼片段的速度的下限;結果向量中"
250
+ "較高的值通常不是由 Python 速度的變化所引起,而是由干擾計時精度的其他行程造成"
251
+ "的。因此,結果中的 :func:`min` 可能是你應該感興趣的唯一數字。在解讀該數據後,"
252
+ "你應該查看整個向量並以常識判讀而非單純仰賴統計資訊。"
205
253
206
254
#: ../../library/timeit.rst:189
207
255
msgid "Helper to print a traceback from the timed code."
208
- msgstr ""
256
+ msgstr "從計時程式碼印出回溯 (traceback) 的輔助函式。 "
209
257
210
258
#: ../../library/timeit.rst:191
211
259
msgid "Typical use::"
212
- msgstr ""
260
+ msgstr "典型用法: :: "
213
261
214
262
#: ../../library/timeit.rst:199
215
263
msgid ""
216
264
"The advantage over the standard traceback is that source lines in the "
217
265
"compiled template will be displayed. The optional *file* argument directs "
218
266
"where the traceback is sent; it defaults to :data:`sys.stderr`."
219
267
msgstr ""
268
+ "相對於標準回溯的優點是,已編譯模板中的原始程式碼會被顯示出來。可選的 *file* "
269
+ "引數指定回溯的發送位置;它預設為 :data:`sys.stderr`。"
220
270
221
271
#: ../../library/timeit.rst:207
222
272
msgid "Command-Line Interface"
223
- msgstr "命令執行列介面 "
273
+ msgstr "命令列介面 "
224
274
225
275
#: ../../library/timeit.rst:209
226
276
msgid ""
227
277
"When called as a program from the command line, the following form is used::"
228
- msgstr ""
278
+ msgstr "當從命令列作為程式呼叫時,請使用以下形式: :: "
229
279
230
280
#: ../../library/timeit.rst:213
231
281
msgid "Where the following options are understood:"
232
- msgstr ""
282
+ msgstr "其中之以下選項: "
233
283
234
284
#: ../../library/timeit.rst:219
235
285
msgid "how many times to execute 'statement'"
236
- msgstr ""
286
+ msgstr "執行 'statement' 多少次 "
237
287
238
288
#: ../../library/timeit.rst:223
239
289
msgid "how many times to repeat the timer (default 5)"
240
- msgstr ""
290
+ msgstr "計時器重複多少次(預設 5) "
241
291
242
292
#: ../../library/timeit.rst:227
243
293
msgid "statement to be executed once initially (default ``pass``)"
244
- msgstr ""
294
+ msgstr "會在一開始執行一次的陳述式(預設為 ``pass``) "
245
295
246
296
#: ../../library/timeit.rst:231
247
297
msgid ""
248
298
"measure process time, not wallclock time, using :func:`time.process_time` "
249
299
"instead of :func:`time.perf_counter`, which is the default"
250
300
msgstr ""
301
+ "若要測量行程時間 (process time) 而非掛鐘時間 (wallclock time),請使用 :func:"
302
+ "`time.process_time` 而不是預設的 :func:`time.perf_counter`"
251
303
252
304
#: ../../library/timeit.rst:238
253
305
msgid ""
254
306
"specify a time unit for timer output; can select ``nsec``, ``usec``, "
255
307
"``msec``, or ``sec``"
256
308
msgstr ""
309
+ "指定定時器輸出的時間單位;可以選擇 ``nsec``、``usec``、``msec`` 或 ``sec``"
257
310
258
311
#: ../../library/timeit.rst:244
259
312
msgid "print raw timing results; repeat for more digits precision"
260
- msgstr ""
313
+ msgstr "印出原始計時結果;重複執行以獲得更高的數字精度 "
261
314
262
315
#: ../../library/timeit.rst:248
263
316
msgid "print a short usage message and exit"
264
- msgstr ""
317
+ msgstr "印出一條簡短的使用訊息並退出 "
265
318
266
319
#: ../../library/timeit.rst:250
267
320
msgid ""
@@ -270,13 +323,18 @@ msgid ""
270
323
"quotes and using leading spaces. Multiple :option:`-s` options are treated "
271
324
"similarly."
272
325
msgstr ""
326
+ "可以透過將每一列陳述式指定為單獨引數來給定多列陳述式;可透過將引數括在引號中"
327
+ "並使用前導空格以實現縮進列 (indented lines)。多個 :option:`-s` 選項的作用類"
328
+ "似。"
273
329
274
330
#: ../../library/timeit.rst:255
275
331
msgid ""
276
332
"If :option:`-n` is not given, a suitable number of loops is calculated by "
277
333
"trying increasing numbers from the sequence 1, 2, 5, 10, 20, 50, ... until "
278
334
"the total time is at least 0.2 seconds."
279
335
msgstr ""
336
+ "如果沒有給定 :option:`-n`,則透過嘗試從序列 1, 2, 5, 10, 20, 50, ... 中增加數"
337
+ "字來計算合適的迴圈次數,直到總時間至少為 0.2 秒。"
280
338
281
339
#: ../../library/timeit.rst:259
282
340
msgid ""
@@ -287,6 +345,10 @@ msgid ""
287
345
"probably enough in most cases. You can use :func:`time.process_time` to "
288
346
"measure CPU time."
289
347
msgstr ""
348
+ ":func:`default_timer` 測量可能會受到同一台機器上運行的其他程式的影響,因此,"
349
+ "當需要精確計時時,最好的做法是重複計時幾次並使用最佳時間。:option:`-r` 選項對"
350
+ "此很有用;在大多數情況下,預設的重複 5 次可能就足夠了。你可以使用 :func:"
351
+ "`time.process_time` 來測量 CPU 時間。"
290
352
291
353
#: ../../library/timeit.rst:267
292
354
msgid ""
@@ -295,6 +357,9 @@ msgid ""
295
357
"it. The baseline overhead can be measured by invoking the program without "
296
358
"arguments, and it might differ between Python versions."
297
359
msgstr ""
360
+ "執行 pass 陳述式會產生一定的基本開銷。這裡的程式碼並不試圖隱藏它,但你應該意"
361
+ "識到它的存在。可以透過不帶引數呼叫程式來測量這個基本開銷,且不同 Python 版本"
362
+ "之間的基本開銷可能有所不同。"
298
363
299
364
#: ../../library/timeit.rst:276
300
365
msgid "Examples"
@@ -304,7 +369,7 @@ msgstr "範例"
304
369
msgid ""
305
370
"It is possible to provide a setup statement that is executed only once at "
306
371
"the beginning:"
307
- msgstr ""
372
+ msgstr "可以提供一個僅會在開始時執行一次的設定陳述式: "
308
373
309
374
#: ../../library/timeit.rst:287
310
375
msgid ""
@@ -315,35 +380,46 @@ msgid ""
315
380
"within the best repetition of the timing loop. That is, the time the fastest "
316
381
"repetition took divided by the loop count."
317
382
msgstr ""
383
+ "輸出中包含三個欄位。迴圈計數,它告訴你每次計時迴圈內重複運行陳述式主體的次"
384
+ "數。重複計數(「最好的 5 次」)告訴你計時迴圈重複了多少次。以及最後陳述式主體"
385
+ "在計時迴圈的最佳的幾次重複執行內平均花費的時間。也就是說,最快的幾次重複執行"
386
+ "所花費的總時間除以迴圈計數。"
318
387
319
388
#: ../../library/timeit.rst:302
320
389
msgid "The same can be done using the :class:`Timer` class and its methods::"
321
- msgstr ""
390
+ msgstr "同樣可以使用 :class:`Timer` 類別及其方法來完成: :: "
322
391
323
392
#: ../../library/timeit.rst:312
324
393
msgid ""
325
394
"The following examples show how to time expressions that contain multiple "
326
395
"lines. Here we compare the cost of using :func:`hasattr` vs. :keyword:`try`/:"
327
396
"keyword:`except` to test for missing and present object attributes:"
328
397
msgstr ""
398
+ "以下範例展示如何對包含多行的運算式進行計時。這裡我們使用 :func:`hasattr` 與 :"
399
+ "keyword:`try`/:keyword:`except` 來測試缺失和存在之物件屬性並比較其花費 "
400
+ "(cost):"
329
401
330
402
#: ../../library/timeit.rst:358
331
403
msgid ""
332
404
"To give the :mod:`timeit` module access to functions you define, you can "
333
405
"pass a *setup* parameter which contains an import statement::"
334
406
msgstr ""
407
+ "要讓 :mod:`timeit` 模組存取你定義的函式,你可以傳遞一個包含 import 陳述式的 "
408
+ "*setup* 參數: ::"
335
409
336
410
#: ../../library/timeit.rst:369
337
411
msgid ""
338
412
"Another option is to pass :func:`globals` to the *globals* parameter, which "
339
413
"will cause the code to be executed within your current global namespace. "
340
414
"This can be more convenient than individually specifying imports::"
341
415
msgstr ""
416
+ "另一種選擇是將 :func:`globals` 傳遞給 *globals* 參數,這將導致程式碼在當前的"
417
+ "全域命名空間中執行,這比單獨指定 import 更方便: ::"
342
418
343
419
#: ../../library/timeit.rst:9
344
420
msgid "Benchmarking"
345
- msgstr ""
421
+ msgstr "基準量測 (Benchmarking) "
346
422
347
423
#: ../../library/timeit.rst:9
348
424
msgid "Performance"
349
- msgstr ""
425
+ msgstr "性能表現 "
0 commit comments