@@ -10,7 +10,7 @@ msgid ""
10
10
msgstr ""
11
11
"Project-Id-Version : Python 3.13\n "
12
12
"Report-Msgid-Bugs-To : \n "
13
- "POT-Creation-Date : 2024-09-03 11:11+0800 \n "
13
+ "POT-Creation-Date : 2025-07-31 00:16+0000 \n "
14
14
"PO-Revision-Date : 2023-08-01 12:53+0800\n "
15
15
"Last-Translator : Matt Wang <mattwang44@gmail.com>\n "
16
16
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -57,10 +57,20 @@ msgstr ""
57
57
"叫 :meth:`~object.__lt__` 方法,並在陣列中的值回傳一個插入點。"
58
58
59
59
#: ../../library/bisect.rst:29
60
+ msgid ""
61
+ "The functions in this module are not thread-safe. If multiple threads "
62
+ "concurrently use :mod:`bisect` functions on the same sequence, this may "
63
+ "result in undefined behaviour. Likewise, if the provided sequence is mutated "
64
+ "by a different thread while a :mod:`bisect` function is operating on it, the "
65
+ "result is undefined. For example, using :py:func:`~bisect.insort_left` on "
66
+ "the same list from multiple threads may result in the list becoming unsorted."
67
+ msgstr ""
68
+
69
+ #: ../../library/bisect.rst:39
60
70
msgid "The following functions are provided:"
61
71
msgstr "此模組提供下面的函式:"
62
72
63
- #: ../../library/bisect.rst:34
73
+ #: ../../library/bisect.rst:44
64
74
msgid ""
65
75
"Locate the insertion point for *x* in *a* to maintain sorted order. The "
66
76
"parameters *lo* and *hi* may be used to specify a subset of the list which "
@@ -74,7 +84,7 @@ msgstr ""
74
84
"有 *x* 出現,插入的位置會在所有 *x* 的前面(左邊)。回傳值可以被當作 ``list."
75
85
"insert()`` 的第一個參數,但列表 *a* 必須先排序過。"
76
86
77
- #: ../../library/bisect.rst:41
87
+ #: ../../library/bisect.rst:51
78
88
msgid ""
79
89
"The returned insertion point *ip* partitions the array *a* into two slices "
80
90
"such that ``all(elem < x for elem in a[lo : ip])`` is true for the left "
@@ -85,7 +95,7 @@ msgstr ""
85
95
"``all(elem < x for elem in a[lo : ip])`` 為真,對於右切片而言 ``all(elem >= "
86
96
"x for elem in a[ip : hi])`` 為真。"
87
97
88
- #: ../../library/bisect.rst:46
98
+ #: ../../library/bisect.rst:56
89
99
msgid ""
90
100
"*key* specifies a :term:`key function` of one argument that is used to "
91
101
"extract a comparison key from each element in the array. To support "
@@ -95,26 +105,26 @@ msgstr ""
95
105
"所有元素以得到比較值來計算順位。注意此 function 只會套用在陣列中的元素,不會"
96
106
"套用在 *x*。"
97
107
98
- #: ../../library/bisect.rst:50
108
+ #: ../../library/bisect.rst:60
99
109
msgid ""
100
110
"If *key* is ``None``, the elements are compared directly and no key function "
101
111
"is called."
102
112
msgstr "若 *key* 為 ``None``,元素將直接進行比較,不會呼叫任何鍵函式。"
103
113
104
- #: ../../library/bisect.rst:53 ../../library/bisect.rst:67
105
- #: ../../library/bisect.rst:85 ../../library/bisect.rst:105
114
+ #: ../../library/bisect.rst:63 ../../library/bisect.rst:77
115
+ #: ../../library/bisect.rst:95 ../../library/bisect.rst:115
106
116
msgid "Added the *key* parameter."
107
117
msgstr "新增 *key* 參數。"
108
118
109
- #: ../../library/bisect.rst:60
119
+ #: ../../library/bisect.rst:70
110
120
msgid ""
111
121
"Similar to :py:func:`~bisect.bisect_left`, but returns an insertion point "
112
122
"which comes after (to the right of) any existing entries of *x* in *a*."
113
123
msgstr ""
114
124
"類似 :py:func:`~bisect.bisect_left`,但回傳的插入位置會在所有 *a* 當中的 *x* "
115
125
"的後面(右邊)。"
116
126
117
- #: ../../library/bisect.rst:63
127
+ #: ../../library/bisect.rst:73
118
128
msgid ""
119
129
"The returned insertion point *ip* partitions the array *a* into two slices "
120
130
"such that ``all(elem <= x for elem in a[lo : ip])`` is true for the left "
@@ -125,11 +135,11 @@ msgstr ""
125
135
"``all(elem <= x for elem in a[lo : ip])`` 為真,對於右切片而言 ``all(elem > "
126
136
"x for elem in a[ip : hi])`` 為真。"
127
137
128
- #: ../../library/bisect.rst:73
138
+ #: ../../library/bisect.rst:83
129
139
msgid "Insert *x* in *a* in sorted order."
130
140
msgstr "將元素 *x* 插入 list *a*,並維持順序。"
131
141
132
- #: ../../library/bisect.rst:75
142
+ #: ../../library/bisect.rst:85
133
143
msgid ""
134
144
"This function first runs :py:func:`~bisect.bisect_left` to locate an "
135
145
"insertion point. Next, it runs the :meth:`!insert` method on *a* to insert "
@@ -138,29 +148,29 @@ msgstr ""
138
148
"此函式先使用 :py:func:`~bisect.bisect_left` 搜尋插入位置,接著用 :meth:`!"
139
149
"insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。"
140
150
141
- #: ../../library/bisect.rst:79 ../../library/bisect.rst:99
151
+ #: ../../library/bisect.rst:89 ../../library/bisect.rst:109
142
152
msgid ""
143
153
"To support inserting records in a table, the *key* function (if any) is "
144
154
"applied to *x* for the search step but not for the insertion step."
145
155
msgstr "此函式只有在搜尋時會使用 *key* 函式,插入時不會。"
146
156
147
- #: ../../library/bisect.rst:82 ../../library/bisect.rst:102
157
+ #: ../../library/bisect.rst:92 ../../library/bisect.rst:112
148
158
msgid ""
149
159
"Keep in mind that the *O*\\ (log *n*) search is dominated by the slow *O*\\ "
150
160
"(*n*) insertion step."
151
161
msgstr ""
152
162
"注意雖然搜尋是 *O*\\ (log *n*),但插入是 *O*\\ (*n*),因此此函式整體時間複雜"
153
163
"度是 *O*\\ (*n*)。"
154
164
155
- #: ../../library/bisect.rst:92
165
+ #: ../../library/bisect.rst:102
156
166
msgid ""
157
167
"Similar to :py:func:`~bisect.insort_left`, but inserting *x* in *a* after "
158
168
"any existing entries of *x*."
159
169
msgstr ""
160
170
"類似 :py:func:`~bisect.insort_left`,但插入的位置會在所有 *a* 當中的 *x* 的後"
161
171
"面(右邊)。"
162
172
163
- #: ../../library/bisect.rst:95
173
+ #: ../../library/bisect.rst:105
164
174
msgid ""
165
175
"This function first runs :py:func:`~bisect.bisect_right` to locate an "
166
176
"insertion point. Next, it runs the :meth:`!insert` method on *a* to insert "
@@ -169,35 +179,35 @@ msgstr ""
169
179
"此函式先使用 :py:func:`~bisect.bisect_right` 搜尋插入位置,接著用 :meth:`!"
170
180
"insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。"
171
181
172
- #: ../../library/bisect.rst:110
182
+ #: ../../library/bisect.rst:120
173
183
msgid "Performance Notes"
174
184
msgstr "效能考量"
175
185
176
- #: ../../library/bisect.rst:112
186
+ #: ../../library/bisect.rst:122
177
187
msgid ""
178
188
"When writing time sensitive code using *bisect()* and *insort()*, keep these "
179
189
"thoughts in mind:"
180
190
msgstr ""
181
191
"若在需要關注寫入時間的程式當中使用 *bisect()* 和 *insort()*,請特別注意幾個事"
182
192
"項:"
183
193
184
- #: ../../library/bisect.rst:115
194
+ #: ../../library/bisect.rst:125
185
195
msgid ""
186
196
"Bisection is effective for searching ranges of values. For locating specific "
187
197
"values, dictionaries are more performant."
188
198
msgstr ""
189
199
"二分法在一段範圍的數值中做搜尋的效率較佳,但若是要存取特定數值,使用字典的表"
190
200
"現還是比較好。"
191
201
192
- #: ../../library/bisect.rst:118
202
+ #: ../../library/bisect.rst:128
193
203
msgid ""
194
204
"The *insort()* functions are *O*\\ (*n*) because the logarithmic search step "
195
205
"is dominated by the linear time insertion step."
196
206
msgstr ""
197
207
"*insort()* 函式的複雜度為 *O*\\ (*n*),因為對數搜尋是以線性時間的插入步驟所主"
198
208
"導 (dominate)。"
199
209
200
- #: ../../library/bisect.rst:121
210
+ #: ../../library/bisect.rst:131
201
211
msgid ""
202
212
"The search functions are stateless and discard key function results after "
203
213
"they are used. Consequently, if the search functions are used in a loop, "
@@ -213,7 +223,7 @@ msgstr ""
213
223
"另外,也可以透過搜尋預先計算好的鍵列表 (array of precomputed keys) 來定位插入"
214
224
"點(如下方範例所示)。"
215
225
216
- #: ../../library/bisect.rst:131
226
+ #: ../../library/bisect.rst:141
217
227
msgid ""
218
228
"`Sorted Collections <https://grantjenks.com/docs/sortedcollections/>`_ is a "
219
229
"high performance module that uses *bisect* to managed sorted collections of "
@@ -222,7 +232,7 @@ msgstr ""
222
232
"`有序容器 (Sorted Collections) <https://grantjenks.com/docs/"
223
233
"sortedcollections/>`_ 是一個使用 *bisect* 來管理資料之有序集合的高效能模組。"
224
234
225
- #: ../../library/bisect.rst:135
235
+ #: ../../library/bisect.rst:145
226
236
msgid ""
227
237
"The `SortedCollection recipe <https://code.activestate.com/recipes/577197-"
228
238
"sortedcollection/>`_ uses bisect to build a full-featured collection class "
@@ -235,11 +245,11 @@ msgstr ""
235
245
"class) 並帶有符合直覺的搜尋方法 (search methods) 與支援鍵函式。鍵會預先被計算"
236
246
"好,以減少搜尋過程中多餘的鍵函式呼叫。"
237
247
238
- #: ../../library/bisect.rst:143
248
+ #: ../../library/bisect.rst:153
239
249
msgid "Searching Sorted Lists"
240
250
msgstr "搜尋一個已排序的 list"
241
251
242
- #: ../../library/bisect.rst:145
252
+ #: ../../library/bisect.rst:155
243
253
msgid ""
244
254
"The above `bisect functions`_ are useful for finding insertion points but "
245
255
"can be tricky or awkward to use for common searching tasks. The following "
@@ -249,7 +259,7 @@ msgstr ""
249
259
"上面的 `bisect functions`_ 在找到數值插入點上很有用,但一般的數值搜尋任務上就"
250
260
"不是那麼的方便。以下的五個函式展示了如何將其轉換成標準的有序列表查找函式: ::"
251
261
252
- #: ../../library/bisect.rst:150
262
+ #: ../../library/bisect.rst:160
253
263
msgid ""
254
264
"def index(a, x):\n"
255
265
" 'Locate the leftmost value exactly equal to x'\n"
@@ -287,11 +297,11 @@ msgid ""
287
297
" raise ValueError"
288
298
msgstr ""
289
299
290
- #: ../../library/bisect.rst:187
300
+ #: ../../library/bisect.rst:197
291
301
msgid "Examples"
292
302
msgstr "範例"
293
303
294
- #: ../../library/bisect.rst:191
304
+ #: ../../library/bisect.rst:201
295
305
msgid ""
296
306
"The :py:func:`~bisect.bisect` function can be useful for numeric table "
297
307
"lookups. This example uses :py:func:`~bisect.bisect` to look up a letter "
@@ -302,7 +312,7 @@ msgstr ""
302
312
"個範例使用 :py:func:`~bisect.bisect` 以基於一組有序的數值分界點來為一個考試成"
303
313
"績找到相對應的字母等級:90 以上是 'A'、80 到 89 為 'B',依此類推: ::"
304
314
305
- #: ../../library/bisect.rst:196
315
+ #: ../../library/bisect.rst:206
306
316
msgid ""
307
317
">>> def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'):\n"
308
318
"... i = bisect(breakpoints, score)\n"
@@ -318,7 +328,7 @@ msgstr ""
318
328
">>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]\n"
319
329
"['F', 'A', 'C', 'C', 'B', 'A', 'A']"
320
330
321
- #: ../../library/bisect.rst:203
331
+ #: ../../library/bisect.rst:213
322
332
msgid ""
323
333
"The :py:func:`~bisect.bisect` and :py:func:`~bisect.insort` functions also "
324
334
"work with lists of tuples. The *key* argument can serve to extract the "
@@ -328,7 +338,7 @@ msgstr ""
328
338
"tuples(元組)的 lists,*key* 引數可被用以取出在數值表中作為排序依據的欄"
329
339
"位: ::"
330
340
331
- #: ../../library/bisect.rst:207
341
+ #: ../../library/bisect.rst:217
332
342
msgid ""
333
343
">>> from collections import namedtuple\n"
334
344
">>> from operator import attrgetter\n"
@@ -361,15 +371,15 @@ msgid ""
361
371
" Movie(name='Titanic', released=1997, director='Cameron')]"
362
372
msgstr ""
363
373
364
- #: ../../library/bisect.rst:237
374
+ #: ../../library/bisect.rst:247
365
375
msgid ""
366
376
"If the key function is expensive, it is possible to avoid repeated function "
367
377
"calls by searching a list of precomputed keys to find the index of a record::"
368
378
msgstr ""
369
379
"如果鍵函式會消耗較多運算資源,那可以在預先計算好的鍵列表中搜尋該紀錄的索引"
370
380
"值,以減少重複的函式呼叫: ::"
371
381
372
- #: ../../library/bisect.rst:240
382
+ #: ../../library/bisect.rst:250
373
383
msgid ""
374
384
">>> data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)]\n"
375
385
">>> data.sort(key=lambda r: r[1]) # Or use operator.itemgetter(1).\n"
0 commit comments