Skip to content

Commit 1cbff10

Browse files
mattwang44claude
andcommitted
Translate c-api/profiling.po
Translate the previously-untranslated entries of the C-API profiling and tracing support documentation into Traditional Chinese, following project terminology and reST conventions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6a4a962 commit 1cbff10

1 file changed

Lines changed: 103 additions & 28 deletions

File tree

c-api/profiling.po

Lines changed: 103 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ msgstr ""
1919

2020
#: ../../c-api/profiling.rst:6
2121
msgid "Profiling and tracing"
22-
msgstr "性能分析與追蹤"
22+
msgstr "效能分析與追蹤"
2323

2424
#: ../../c-api/profiling.rst:8
2525
msgid ""
2626
"The Python interpreter provides some low-level support for attaching "
2727
"profiling and execution tracing facilities. These are used for profiling, "
2828
"debugging, and coverage analysis tools."
2929
msgstr ""
30+
"Python 直譯器提供了一些底層支援,用於附加效能分析與執行追蹤的機制。這些功能會"
31+
"被用於效能分析、除錯以及覆蓋率分析工具。"
3032

3133
#: ../../c-api/profiling.rst:12
3234
msgid ""
@@ -37,18 +39,25 @@ msgid ""
3739
"basic events reported to the trace function are the same as had been "
3840
"reported to the Python-level trace functions in previous versions."
3941
msgstr ""
42+
"此 C 介面讓效能分析或追蹤的程式碼能夠避免透過 Python 層級的可呼叫物件進行呼叫"
43+
"所帶來的開銷,而是改為直接進行 C 函式呼叫。此機制的基本屬性並未改變;該介面允"
44+
"許追蹤函式以每執行緒(per-thread)為單位安裝,而回報給追蹤函式的基本事件,與"
45+
"先前版本中回報給 Python 層級追蹤函式的事件相同。"
4046

4147
#: ../../c-api/profiling.rst:22
4248
msgid ""
4349
"The type of the trace function registered using :c:func:`PyEval_SetProfile` "
4450
"and :c:func:`PyEval_SetTrace`. The first parameter is the object passed to "
4551
"the registration function as *obj*, *frame* is the frame object to which the "
46-
"event pertains, *what* is one of the constants :c:data:`PyTrace_CALL`, :c:"
47-
"data:`PyTrace_EXCEPTION`, :c:data:`PyTrace_LINE`, :c:data:`PyTrace_RETURN`, :"
48-
"c:data:`PyTrace_C_CALL`, :c:data:`PyTrace_C_EXCEPTION`, :c:data:"
49-
"`PyTrace_C_RETURN`, or :c:data:`PyTrace_OPCODE`, and *arg* depends on the "
50-
"value of *what*:"
52+
"event pertains, *what* is one of the "
53+
"constants :c:data:`PyTrace_CALL`, :c:data:`PyTrace_EXCEPTION`, :c:data:`PyTrace_LINE`, :c:data:`PyTrace_RETURN`, :c:data:`PyTrace_C_CALL`, :c:data:`PyTrace_C_EXCEPTION`, :c:data:`PyTrace_C_RETURN`, "
54+
"or :c:data:`PyTrace_OPCODE`, and *arg* depends on the value of *what*:"
5155
msgstr ""
56+
"使用 :c:func:`PyEval_SetProfile` 和 :c:func:`PyEval_SetTrace` 註冊的追蹤函式"
57+
"的型別。第一個參數是作為 *obj* 傳遞給註冊函式的物件,*frame* 是該事件所屬的框"
58+
"架(frame)物件,*what* 是常"
59+
"數 :c:data:`PyTrace_CALL`、:c:data:`PyTrace_EXCEPTION`、:c:data:`PyTrace_LINE`、:c:data:`PyTrace_RETURN`、:c:data:`PyTrace_C_CALL`、:c:data:`PyTrace_C_EXCEPTION`、:c:data:`PyTrace_C_RETURN` "
60+
"或 :c:data:`PyTrace_OPCODE` 其中之一,而 *arg* 則取決於 *what* 的值:"
5261

5362
#: ../../c-api/profiling.rst:31
5463
msgid "Value of *what*"
@@ -73,7 +82,7 @@ msgstr ":c:data:`PyTrace_EXCEPTION`"
7382

7483
#: ../../c-api/profiling.rst:35
7584
msgid "Exception information as returned by :func:`sys.exc_info`."
76-
msgstr ""
85+
msgstr "由 :func:`sys.exc_info` 回傳的例外資訊。"
7786

7887
#: ../../c-api/profiling.rst:38
7988
msgid ":c:data:`PyTrace_LINE`"
@@ -86,7 +95,7 @@ msgstr ":c:data:`PyTrace_RETURN`"
8695
#: ../../c-api/profiling.rst:40
8796
msgid ""
8897
"Value being returned to the caller, or ``NULL`` if caused by an exception."
89-
msgstr ""
98+
msgstr "回傳給呼叫者的值,若是由例外所引起則為 ``NULL``。"
9099

91100
#: ../../c-api/profiling.rst:43
92101
msgid ":c:data:`PyTrace_C_CALL`"
@@ -117,6 +126,10 @@ msgid ""
117126
"is not reported as there is no control transfer to the Python bytecode in "
118127
"the corresponding frame."
119128
msgstr ""
129+
"當回報一個對函式或方法的新呼叫,或進入產生器的新進入點時,傳遞"
130+
"給 :c:type:`Py_tracefunc` 函式的 *what* 參數的值。請注意,產生器函式的疊代器"
131+
"之建立並不會被回報,因為在對應的框架(frame)中並沒有控制權轉移到 Python 位元"
132+
"組碼。"
120133

121134
#: ../../c-api/profiling.rst:63
122135
msgid ""
@@ -129,56 +142,79 @@ msgid ""
129142
"Only trace functions receive these events; they are not needed by the "
130143
"profiler."
131144
msgstr ""
145+
"當例外被引發時,傳遞給 :c:type:`Py_tracefunc` 函式的 *what* 參數的值。在任何"
146+
"位元組碼被處理後,若例外在正在執行的框架(frame)內被設定,回呼函式就會以此 "
147+
"*what* 值被呼叫。其效果是,當例外傳播導致 Python 堆疊回溯(unwind)時,隨著例"
148+
"外傳播,每當返回到各個框架時就會呼叫該回呼。只有追蹤函式會收到這些事件;效能"
149+
"分析器並不需要它們。"
132150

133151
#: ../../c-api/profiling.rst:74
134152
msgid ""
135153
"The value passed as the *what* parameter to a :c:type:`Py_tracefunc` "
136154
"function (but not a profiling function) when a line-number event is being "
137-
"reported. It may be disabled for a frame by setting :attr:`~frame."
138-
"f_trace_lines` to *0* on that frame."
155+
"reported. It may be disabled for a frame by "
156+
"setting :attr:`~frame.f_trace_lines` to *0* on that frame."
139157
msgstr ""
158+
"當回報一個列號(line-number)事件時,傳遞給 :c:type:`Py_tracefunc` 函式(但非"
159+
"效能分析函式)的 *what* 參數的值。可藉由將該框架(frame)上"
160+
"的 :attr:`~frame.f_trace_lines` 設為 *0* 來為該框架停用它。"
140161

141162
#: ../../c-api/profiling.rst:82
142163
msgid ""
143164
"The value for the *what* parameter to :c:type:`Py_tracefunc` functions when "
144165
"a call is about to return."
145166
msgstr ""
167+
"當一個呼叫即將回傳時,傳遞給 :c:type:`Py_tracefunc` 函式的 *what* 參數的值。"
146168

147169
#: ../../c-api/profiling.rst:88
148170
msgid ""
149171
"The value for the *what* parameter to :c:type:`Py_tracefunc` functions when "
150172
"a C function is about to be called."
151173
msgstr ""
174+
"當一個 C 函式即將被呼叫時,傳遞給 :c:type:`Py_tracefunc` 函式的 *what* 參數的"
175+
"值。"
152176

153177
#: ../../c-api/profiling.rst:94
154178
msgid ""
155179
"The value for the *what* parameter to :c:type:`Py_tracefunc` functions when "
156180
"a C function has raised an exception."
157181
msgstr ""
182+
"當一個 C 函式已引發例外時,傳遞給 :c:type:`Py_tracefunc` 函式的 *what* 參數的"
183+
"值。"
158184

159185
#: ../../c-api/profiling.rst:100
160186
msgid ""
161187
"The value for the *what* parameter to :c:type:`Py_tracefunc` functions when "
162188
"a C function has returned."
163189
msgstr ""
190+
"當一個 C 函式已回傳時,傳遞給 :c:type:`Py_tracefunc` 函式的 *what* 參數的值。"
164191

165192
#: ../../c-api/profiling.rst:106
166193
msgid ""
167194
"The value for the *what* parameter to :c:type:`Py_tracefunc` functions (but "
168195
"not profiling functions) when a new opcode is about to be executed. This "
169-
"event is not emitted by default: it must be explicitly requested by setting :"
170-
"attr:`~frame.f_trace_opcodes` to *1* on the frame."
196+
"event is not emitted by default: it must be explicitly requested by "
197+
"setting :attr:`~frame.f_trace_opcodes` to *1* on the frame."
171198
msgstr ""
199+
"當一個新的運算碼(opcode)即將被執行時,傳遞給 :c:type:`Py_tracefunc` 函式"
200+
"(但非效能分析函式)的 *what* 參數的值。此事件預設不會被發出:它必須藉由將該"
201+
"框架(frame)上的 :attr:`~frame.f_trace_opcodes` 設為 *1* 來明確地請求。"
172202

173203
#: ../../c-api/profiling.rst:114
174204
msgid ""
175205
"Set the profiler function to *func*. The *obj* parameter is passed to the "
176206
"function as its first parameter, and may be any Python object, or ``NULL``. "
177207
"If the profile function needs to maintain state, using a different value for "
178208
"*obj* for each thread provides a convenient and thread-safe place to store "
179-
"it. The profile function is called for all monitored events except :c:data:"
180-
"`PyTrace_LINE` :c:data:`PyTrace_OPCODE` and :c:data:`PyTrace_EXCEPTION`."
209+
"it. The profile function is called for all monitored events "
210+
"except :c:data:`PyTrace_LINE` :c:data:`PyTrace_OPCODE` "
211+
"and :c:data:`PyTrace_EXCEPTION`."
181212
msgstr ""
213+
"將效能分析器函式設為 *func*。*obj* 參數會作為函式的第一個參數傳遞,且可以是任"
214+
"何 Python 物件或 ``NULL``。如果效能分析函式需要維護狀態,為每個執行緒的 "
215+
"*obj* 使用不同的值,能提供一個方便且執行緒安全的儲存位置。效能分析函式會針對"
216+
"所有被監控的事件被呼叫,但 :c:data:`PyTrace_LINE`、:c:data:`PyTrace_OPCODE` "
217+
"和 :c:data:`PyTrace_EXCEPTION` 除外。"
182218

183219
#: ../../c-api/profiling.rst:121
184220
msgid "See also the :func:`sys.setprofile` function."
@@ -195,23 +231,32 @@ msgid ""
195231
"running threads belonging to the current interpreter instead of the setting "
196232
"it only on the current thread."
197233
msgstr ""
234+
"與 :c:func:`PyEval_SetProfile` 類似,但會在所有屬於目前直譯器的執行中執行緒上"
235+
"設定效能分析函式,而非僅在目前的執行緒上設定。"
198236

199237
#: ../../c-api/profiling.rst:133
200238
msgid ""
201239
"As :c:func:`PyEval_SetProfile`, this function ignores any exceptions raised "
202240
"while setting the profile functions in all threads."
203241
msgstr ""
242+
"如同 :c:func:`PyEval_SetProfile`,此函式會忽略在所有執行緒上設定效能分析函式"
243+
"時所引發的任何例外。"
204244

205245
#: ../../c-api/profiling.rst:141
206246
msgid ""
207-
"Set the tracing function to *func*. This is similar to :c:func:"
208-
"`PyEval_SetProfile`, except the tracing function does receive line-number "
209-
"events and per-opcode events, but does not receive any event related to C "
210-
"function objects being called. Any trace function registered using :c:func:"
211-
"`PyEval_SetTrace` will not receive :c:data:`PyTrace_C_CALL`, :c:data:"
212-
"`PyTrace_C_EXCEPTION` or :c:data:`PyTrace_C_RETURN` as a value for the "
213-
"*what* parameter."
247+
"Set the tracing function to *func*. This is similar "
248+
"to :c:func:`PyEval_SetProfile`, except the tracing function does receive "
249+
"line-number events and per-opcode events, but does not receive any event "
250+
"related to C function objects being called. Any trace function registered "
251+
"using :c:func:`PyEval_SetTrace` will not "
252+
"receive :c:data:`PyTrace_C_CALL`, :c:data:`PyTrace_C_EXCEPTION` "
253+
"or :c:data:`PyTrace_C_RETURN` as a value for the *what* parameter."
214254
msgstr ""
255+
"將追蹤函式設為 *func*。這與 :c:func:`PyEval_SetProfile` 類似,差別在於追蹤函"
256+
"式確實會收到列號(line-number)事件與逐運算碼(per-opcode)事件,但不會收到任"
257+
"何與被呼叫的 C 函式物件相關的事件。任何使用 :c:func:`PyEval_SetTrace` 註冊的"
258+
"追蹤函式都不會收到 :c:data:`PyTrace_C_CALL`、:c:data:`PyTrace_C_EXCEPTION` "
259+
"或 :c:data:`PyTrace_C_RETURN` 作為 *what* 參數的值。"
215260

216261
#: ../../c-api/profiling.rst:148
217262
msgid "See also the :func:`sys.settrace` function."
@@ -223,26 +268,35 @@ msgid ""
223268
"threads belonging to the current interpreter instead of the setting it only "
224269
"on the current thread."
225270
msgstr ""
271+
"與 :c:func:`PyEval_SetTrace` 類似,但會在所有屬於目前直譯器的執行中執行緒上設"
272+
"定追蹤函式,而非僅在目前的執行緒上設定。"
226273

227274
#: ../../c-api/profiling.rst:160
228275
msgid ""
229276
"As :c:func:`PyEval_SetTrace`, this function ignores any exceptions raised "
230277
"while setting the trace functions in all threads."
231278
msgstr ""
279+
"如同 :c:func:`PyEval_SetTrace`,此函式會忽略在所有執行緒上設定追蹤函式時所引"
280+
"發的任何例外。"
232281

233282
#: ../../c-api/profiling.rst:167
234283
msgid "Reference tracing"
235284
msgstr "參照追蹤"
236285

237286
#: ../../c-api/profiling.rst:174
238287
msgid ""
239-
"The type of the trace function registered using :c:func:"
240-
"`PyRefTracer_SetTracer`. The first parameter is a Python object that has "
241-
"been just created (when **event** is set to :c:data:`PyRefTracer_CREATE`) or "
242-
"about to be destroyed (when **event** is set to :c:data:"
243-
"`PyRefTracer_DESTROY`). The **data** argument is the opaque pointer that was "
244-
"provided when :c:func:`PyRefTracer_SetTracer` was called."
288+
"The type of the trace function registered "
289+
"using :c:func:`PyRefTracer_SetTracer`. The first parameter is a Python "
290+
"object that has been just created (when **event** is set "
291+
"to :c:data:`PyRefTracer_CREATE`) or about to be destroyed (when **event** is "
292+
"set to :c:data:`PyRefTracer_DESTROY`). The **data** argument is the opaque "
293+
"pointer that was provided when :c:func:`PyRefTracer_SetTracer` was called."
245294
msgstr ""
295+
"使用 :c:func:`PyRefTracer_SetTracer` 註冊的追蹤函式的型別。第一個參數是一個剛"
296+
"被建立(當 **event** 設為 :c:data:`PyRefTracer_CREATE` 時)或即將被銷毀(當 "
297+
"**event** 設為 :c:data:`PyRefTracer_DESTROY` 時)的 Python 物件。**data** 引"
298+
"數是呼叫 :c:func:`PyRefTracer_SetTracer` 時所提供的不透明指標(opaque "
299+
"pointer)。"
246300

247301
#: ../../c-api/profiling.rst:180
248302
msgid ""
@@ -251,24 +305,33 @@ msgid ""
251305
"**event** set to :c:data:`PyRefTracer_TRACKER_REMOVED`. This will happen "
252306
"just before the new function is registered."
253307
msgstr ""
308+
"如果註冊了一個新的追蹤函式來取代目前的追蹤函式,將會以物件設為 **NULL** 且 "
309+
"**event** 設為 :c:data:`PyRefTracer_TRACKER_REMOVED` 的方式對追蹤函式進行一次"
310+
"呼叫。這會在新函式被註冊之前發生。"
254311

255312
#: ../../c-api/profiling.rst:190
256313
msgid ""
257314
"The value for the *event* parameter to :c:type:`PyRefTracer` functions when "
258315
"a Python object has been created."
259316
msgstr ""
317+
"當一個 Python 物件已被建立時,傳遞給 :c:type:`PyRefTracer` 函式的 *event* 參"
318+
"數的值。"
260319

261320
#: ../../c-api/profiling.rst:196
262321
msgid ""
263322
"The value for the *event* parameter to :c:type:`PyRefTracer` functions when "
264323
"a Python object has been destroyed."
265324
msgstr ""
325+
"當一個 Python 物件已被銷毀時,傳遞給 :c:type:`PyRefTracer` 函式的 *event* 參"
326+
"數的值。"
266327

267328
#: ../../c-api/profiling.rst:202
268329
msgid ""
269330
"The value for the *event* parameter to :c:type:`PyRefTracer` functions when "
270331
"the current tracer is about to be replaced by a new one."
271332
msgstr ""
333+
"當目前的追蹤器即將被一個新的追蹤器取代時,傳遞給 :c:type:`PyRefTracer` 函式"
334+
"的 *event* 參數的值。"
272335

273336
#: ../../c-api/profiling.rst:210
274337
msgid ""
@@ -278,6 +341,10 @@ msgid ""
278341
"when the tracer function is called. Return ``0`` on success. Set an "
279342
"exception and return ``-1`` on error."
280343
msgstr ""
344+
"註冊一個參照追蹤器函式。當一個新的 Python 物件已被建立,或當一個物件即將被銷"
345+
"毀時,該函式就會被呼叫。如果有提供 **data**,它必須是一個不透明指標(opaque "
346+
"pointer),會在追蹤器函式被呼叫時提供。成功時回傳 ``0``。錯誤時設定一個例外並"
347+
"回傳 ``-1``。"
281348

282349
#: ../../c-api/profiling.rst:216
283350
msgid ""
@@ -286,18 +353,23 @@ msgid ""
286353
"any existing exception or set an exception. A :term:`thread state` will be "
287354
"active every time the tracer function is called."
288355
msgstr ""
356+
"請注意,追蹤器函式 **不可以** 在內部建立 Python 物件,否則該呼叫將會是可重入"
357+
"的(re-entrant)。追蹤器也 **不可以** 清除任何既有的例外或設定例外。每次呼叫"
358+
"追蹤器函式時,都會有一個 :term:`執行緒狀態 <thread state>` 處於作用中。"
289359

290360
#: ../../c-api/profiling.rst:221 ../../c-api/profiling.rst:237
291361
msgid ""
292362
"There must be an :term:`attached thread state` when calling this function."
293-
msgstr ""
363+
msgstr "呼叫此函式時必須有一個 :term:`attached thread state`。"
294364

295365
#: ../../c-api/profiling.rst:223
296366
msgid ""
297367
"If another tracer function was already registered, the old function will be "
298368
"called with **event** set to :c:data:`PyRefTracer_TRACKER_REMOVED` just "
299369
"before the new function is registered."
300370
msgstr ""
371+
"如果先前已註冊了另一個追蹤器函式,則在新函式被註冊之前,舊函式會以 **event** "
372+
"設為 :c:data:`PyRefTracer_TRACKER_REMOVED` 的方式被呼叫。"
301373

302374
#: ../../c-api/profiling.rst:232
303375
msgid ""
@@ -306,3 +378,6 @@ msgid ""
306378
"called. If no tracer was registered this function will return NULL and will "
307379
"set the **data** pointer to NULL."
308380
msgstr ""
381+
"取得已註冊的參照追蹤器函式,以及呼叫 :c:func:`PyRefTracer_SetTracer` 時所註冊"
382+
"的不透明資料指標(opaque data pointer)的值。如果沒有註冊任何追蹤器,此函式將"
383+
"回傳 NULL 並會將 **data** 指標設為 NULL。"

0 commit comments

Comments
 (0)