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

Translatelibrary/timeit.po#650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mattwang44 merged 2 commits intopython:3.12frommattwang44:library/timeit
Sep 18, 2023
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 103 additions & 27 deletionslibrary/timeit.po
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -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 <adrianliaw2000@gmail.com>, 2018
# Matt Wang <mattwang44@gmail.com>, 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 <adrianliaw2000@gmail.com>\n"
"Last-Translator:Matt Wang <mattwang44@gmail.com>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
Expand All@@ -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:"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

這邊的空格(中文與英文之間)應該要保留吧?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

你可以看看 preview,render 出來會是中文

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

除了直接make出html來看之外,還有別的方法能知道 render 出來的文字嗎?
我一直以為像你貼的那張圖一樣,如果要render出中文就要寫得像 :ref:可呼叫介面 <python-interface> 這樣
所以我在看 :ref:timeit-command-line-interface 的時候才會覺得render出來會是英文

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

TBH 看 build 出來的結果再決定是最直接的,因為也不好判斷 reference 到的那個 string 有沒有被翻譯(也有可能翻譯的當下 ref string 還沒翻但後來又被翻譯了)。想要做到看到 syntax 就知道他是否可能會跑出譯文的話,可能就要先讀懂 sphinx & cpython doc 裡面設定的規則與慣例,不過當然 efforts 就比較大。

ken71301 reacted with thumbs up emoji
"`timeit-command-line-interface`\\ 和一個\\ :ref:`可呼叫介面 <python-"
"interface>`,它避免了許多測量執行時間的常見陷阱。另請參閱由 O'Reilly 出版的 "
"*Python 錦囊妙計 (Python Cookbook)* 第二版中 Tim Peters 所寫的「演算法」章節"
"的介紹。"

#: ../../library/timeit.rst:23
msgid "Basic Examples"
Expand All@@ -45,29 +51,33 @@ 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`\\ 來比較三個不"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

在rst語法內看到 "\ " 是在顯示時忽略這個空格對吧? 我想確認一下:D

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

避免其實是我搞混...

Copy link
CollaboratorAuthor

@mattwang44mattwang44Sep 14, 2023
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

對,讓它有空格的效果,但不要 render 出空格

image
(應該要把這張圖的內容整理到 wiki 但一直還沒做...)

"同的運算式:"

#: ../../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 ""
"Note however that :func:`.timeit` will automatically determine the number of "
"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 ""
Expand All@@ -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
Expand All@@ -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 ""
Expand All@@ -118,19 +136,26 @@ 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 ""
"To measure the execution time of the first statement, use the :meth:`."
"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 ""
Expand All@@ -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 ""
Expand All@@ -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 ""
Expand All@@ -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:`垃圾回收 <garbage "
"collection>`。這種方法的優點是它使獨立時序更具可比較性,缺點是 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 ""
Expand All@@ -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 ""
Expand All@@ -190,6 +230,9 @@ msgid ""
"call :meth:`.timeit`. The second argument specifies the *number* argument "
"for :meth:`.timeit`."
msgstr ""
"這是一個方便的函式,它會重複呼叫 :meth:`.timeit` 並回傳結果列表。第一個引數指"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

這裡的list 該翻譯成 列表 還是 串列 ?

Copy link
CollaboratorAuthor

@mattwang44mattwang44Sep 16, 2023
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

我是覺得都可以。覺得可以翻成「結果列表」(他其實就是個串列,只是列表與串列英文都是 list)或是「包含結果的串列」

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

我是覺得list翻成列表也很順(只是術語表裡面寫串列),這邊應該是都可以啦

"定呼叫 :meth:`.timeit` 的次數,第二個引數指定 :meth:`.timeit` 的 *number* 引"
"數。"

#: ../../library/timeit.rst:173
msgid ""
Expand All@@ -202,66 +245,76 @@ 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 ""
"The advantage over the standard traceback is that source lines in the "
"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 ""
Expand All@@ -270,13 +323,18 @@ msgid ""
"quotes and using leading spaces. Multiple :option:`-s` options are treated "
"similarly."
msgstr ""
"可以透過將每一列陳述式指定為單獨引數來給定多列陳述式;可透過將引數括在引號中"
"並使用前導空格以實現縮進列 (indented lines)。多個 :option:`-s` 選項的作用類"
"似。"

#: ../../library/timeit.rst:255
msgid ""
"If :option:`-n` is not given, a suitable number of loops is calculated by "
"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 ""
Expand All@@ -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 ""
Expand All@@ -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"
Expand All@@ -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 ""
Expand All@@ -315,35 +380,46 @@ 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 ""
"The following examples show how to time expressions that contain multiple "
"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 ""
"Another option is to pass :func:`globals` to the *globals* parameter, which "
"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 "性能表現"

[8]ページ先頭

©2009-2025 Movatter.jp