Skip to content

Commit f3fb9ca

Browse files
sync with cpython 5c16f699
1 parent d66eab6 commit f3fb9ca

File tree

1 file changed

+42
-32
lines changed

1 file changed

+42
-32
lines changed

library/bisect.po

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ msgid ""
1010
msgstr ""
1111
"Project-Id-Version: Python 3.13\n"
1212
"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"
1414
"PO-Revision-Date: 2023-08-01 12:53+0800\n"
1515
"Last-Translator: Matt Wang <mattwang44@gmail.com>\n"
1616
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -57,10 +57,20 @@ msgstr ""
5757
"叫 :meth:`~object.__lt__` 方法,並在陣列中的值回傳一個插入點。"
5858

5959
#: ../../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
6070
msgid "The following functions are provided:"
6171
msgstr "此模組提供下面的函式:"
6272

63-
#: ../../library/bisect.rst:34
73+
#: ../../library/bisect.rst:44
6474
msgid ""
6575
"Locate the insertion point for *x* in *a* to maintain sorted order. The "
6676
"parameters *lo* and *hi* may be used to specify a subset of the list which "
@@ -74,7 +84,7 @@ msgstr ""
7484
"有 *x* 出現,插入的位置會在所有 *x* 的前面(左邊)。回傳值可以被當作 ``list."
7585
"insert()`` 的第一個參數,但列表 *a* 必須先排序過。"
7686

77-
#: ../../library/bisect.rst:41
87+
#: ../../library/bisect.rst:51
7888
msgid ""
7989
"The returned insertion point *ip* partitions the array *a* into two slices "
8090
"such that ``all(elem < x for elem in a[lo : ip])`` is true for the left "
@@ -85,7 +95,7 @@ msgstr ""
8595
"``all(elem < x for elem in a[lo : ip])`` 為真,對於右切片而言 ``all(elem >= "
8696
"x for elem in a[ip : hi])`` 為真。"
8797

88-
#: ../../library/bisect.rst:46
98+
#: ../../library/bisect.rst:56
8999
msgid ""
90100
"*key* specifies a :term:`key function` of one argument that is used to "
91101
"extract a comparison key from each element in the array. To support "
@@ -95,26 +105,26 @@ msgstr ""
95105
"所有元素以得到比較值來計算順位。注意此 function 只會套用在陣列中的元素,不會"
96106
"套用在 *x*。"
97107

98-
#: ../../library/bisect.rst:50
108+
#: ../../library/bisect.rst:60
99109
msgid ""
100110
"If *key* is ``None``, the elements are compared directly and no key function "
101111
"is called."
102112
msgstr "若 *key* 為 ``None``,元素將直接進行比較,不會呼叫任何鍵函式。"
103113

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
106116
msgid "Added the *key* parameter."
107117
msgstr "新增 *key* 參數。"
108118

109-
#: ../../library/bisect.rst:60
119+
#: ../../library/bisect.rst:70
110120
msgid ""
111121
"Similar to :py:func:`~bisect.bisect_left`, but returns an insertion point "
112122
"which comes after (to the right of) any existing entries of *x* in *a*."
113123
msgstr ""
114124
"類似 :py:func:`~bisect.bisect_left`,但回傳的插入位置會在所有 *a* 當中的 *x* "
115125
"的後面(右邊)。"
116126

117-
#: ../../library/bisect.rst:63
127+
#: ../../library/bisect.rst:73
118128
msgid ""
119129
"The returned insertion point *ip* partitions the array *a* into two slices "
120130
"such that ``all(elem <= x for elem in a[lo : ip])`` is true for the left "
@@ -125,11 +135,11 @@ msgstr ""
125135
"``all(elem <= x for elem in a[lo : ip])`` 為真,對於右切片而言 ``all(elem > "
126136
"x for elem in a[ip : hi])`` 為真。"
127137

128-
#: ../../library/bisect.rst:73
138+
#: ../../library/bisect.rst:83
129139
msgid "Insert *x* in *a* in sorted order."
130140
msgstr "將元素 *x* 插入 list *a*,並維持順序。"
131141

132-
#: ../../library/bisect.rst:75
142+
#: ../../library/bisect.rst:85
133143
msgid ""
134144
"This function first runs :py:func:`~bisect.bisect_left` to locate an "
135145
"insertion point. Next, it runs the :meth:`!insert` method on *a* to insert "
@@ -138,29 +148,29 @@ msgstr ""
138148
"此函式先使用 :py:func:`~bisect.bisect_left` 搜尋插入位置,接著用 :meth:`!"
139149
"insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。"
140150

141-
#: ../../library/bisect.rst:79 ../../library/bisect.rst:99
151+
#: ../../library/bisect.rst:89 ../../library/bisect.rst:109
142152
msgid ""
143153
"To support inserting records in a table, the *key* function (if any) is "
144154
"applied to *x* for the search step but not for the insertion step."
145155
msgstr "此函式只有在搜尋時會使用 *key* 函式,插入時不會。"
146156

147-
#: ../../library/bisect.rst:82 ../../library/bisect.rst:102
157+
#: ../../library/bisect.rst:92 ../../library/bisect.rst:112
148158
msgid ""
149159
"Keep in mind that the *O*\\ (log *n*) search is dominated by the slow *O*\\ "
150160
"(*n*) insertion step."
151161
msgstr ""
152162
"注意雖然搜尋是 *O*\\ (log *n*),但插入是 *O*\\ (*n*),因此此函式整體時間複雜"
153163
"度是 *O*\\ (*n*)。"
154164

155-
#: ../../library/bisect.rst:92
165+
#: ../../library/bisect.rst:102
156166
msgid ""
157167
"Similar to :py:func:`~bisect.insort_left`, but inserting *x* in *a* after "
158168
"any existing entries of *x*."
159169
msgstr ""
160170
"類似 :py:func:`~bisect.insort_left`,但插入的位置會在所有 *a* 當中的 *x* 的後"
161171
"面(右邊)。"
162172

163-
#: ../../library/bisect.rst:95
173+
#: ../../library/bisect.rst:105
164174
msgid ""
165175
"This function first runs :py:func:`~bisect.bisect_right` to locate an "
166176
"insertion point. Next, it runs the :meth:`!insert` method on *a* to insert "
@@ -169,35 +179,35 @@ msgstr ""
169179
"此函式先使用 :py:func:`~bisect.bisect_right` 搜尋插入位置,接著用 :meth:`!"
170180
"insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。"
171181

172-
#: ../../library/bisect.rst:110
182+
#: ../../library/bisect.rst:120
173183
msgid "Performance Notes"
174184
msgstr "效能考量"
175185

176-
#: ../../library/bisect.rst:112
186+
#: ../../library/bisect.rst:122
177187
msgid ""
178188
"When writing time sensitive code using *bisect()* and *insort()*, keep these "
179189
"thoughts in mind:"
180190
msgstr ""
181191
"若在需要關注寫入時間的程式當中使用 *bisect()* 和 *insort()*,請特別注意幾個事"
182192
"項:"
183193

184-
#: ../../library/bisect.rst:115
194+
#: ../../library/bisect.rst:125
185195
msgid ""
186196
"Bisection is effective for searching ranges of values. For locating specific "
187197
"values, dictionaries are more performant."
188198
msgstr ""
189199
"二分法在一段範圍的數值中做搜尋的效率較佳,但若是要存取特定數值,使用字典的表"
190200
"現還是比較好。"
191201

192-
#: ../../library/bisect.rst:118
202+
#: ../../library/bisect.rst:128
193203
msgid ""
194204
"The *insort()* functions are *O*\\ (*n*) because the logarithmic search step "
195205
"is dominated by the linear time insertion step."
196206
msgstr ""
197207
"*insort()* 函式的複雜度為 *O*\\ (*n*),因為對數搜尋是以線性時間的插入步驟所主"
198208
"導 (dominate)。"
199209

200-
#: ../../library/bisect.rst:121
210+
#: ../../library/bisect.rst:131
201211
msgid ""
202212
"The search functions are stateless and discard key function results after "
203213
"they are used. Consequently, if the search functions are used in a loop, "
@@ -213,7 +223,7 @@ msgstr ""
213223
"另外,也可以透過搜尋預先計算好的鍵列表 (array of precomputed keys) 來定位插入"
214224
"點(如下方範例所示)。"
215225

216-
#: ../../library/bisect.rst:131
226+
#: ../../library/bisect.rst:141
217227
msgid ""
218228
"`Sorted Collections <https://grantjenks.com/docs/sortedcollections/>`_ is a "
219229
"high performance module that uses *bisect* to managed sorted collections of "
@@ -222,7 +232,7 @@ msgstr ""
222232
"`有序容器 (Sorted Collections) <https://grantjenks.com/docs/"
223233
"sortedcollections/>`_ 是一個使用 *bisect* 來管理資料之有序集合的高效能模組。"
224234

225-
#: ../../library/bisect.rst:135
235+
#: ../../library/bisect.rst:145
226236
msgid ""
227237
"The `SortedCollection recipe <https://code.activestate.com/recipes/577197-"
228238
"sortedcollection/>`_ uses bisect to build a full-featured collection class "
@@ -235,11 +245,11 @@ msgstr ""
235245
"class) 並帶有符合直覺的搜尋方法 (search methods) 與支援鍵函式。鍵會預先被計算"
236246
"好,以減少搜尋過程中多餘的鍵函式呼叫。"
237247

238-
#: ../../library/bisect.rst:143
248+
#: ../../library/bisect.rst:153
239249
msgid "Searching Sorted Lists"
240250
msgstr "搜尋一個已排序的 list"
241251

242-
#: ../../library/bisect.rst:145
252+
#: ../../library/bisect.rst:155
243253
msgid ""
244254
"The above `bisect functions`_ are useful for finding insertion points but "
245255
"can be tricky or awkward to use for common searching tasks. The following "
@@ -249,7 +259,7 @@ msgstr ""
249259
"上面的 `bisect functions`_ 在找到數值插入點上很有用,但一般的數值搜尋任務上就"
250260
"不是那麼的方便。以下的五個函式展示了如何將其轉換成標準的有序列表查找函式: ::"
251261

252-
#: ../../library/bisect.rst:150
262+
#: ../../library/bisect.rst:160
253263
msgid ""
254264
"def index(a, x):\n"
255265
" 'Locate the leftmost value exactly equal to x'\n"
@@ -287,11 +297,11 @@ msgid ""
287297
" raise ValueError"
288298
msgstr ""
289299

290-
#: ../../library/bisect.rst:187
300+
#: ../../library/bisect.rst:197
291301
msgid "Examples"
292302
msgstr "範例"
293303

294-
#: ../../library/bisect.rst:191
304+
#: ../../library/bisect.rst:201
295305
msgid ""
296306
"The :py:func:`~bisect.bisect` function can be useful for numeric table "
297307
"lookups. This example uses :py:func:`~bisect.bisect` to look up a letter "
@@ -302,7 +312,7 @@ msgstr ""
302312
"個範例使用 :py:func:`~bisect.bisect` 以基於一組有序的數值分界點來為一個考試成"
303313
"績找到相對應的字母等級:90 以上是 'A'、80 到 89 為 'B',依此類推: ::"
304314

305-
#: ../../library/bisect.rst:196
315+
#: ../../library/bisect.rst:206
306316
msgid ""
307317
">>> def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'):\n"
308318
"... i = bisect(breakpoints, score)\n"
@@ -318,7 +328,7 @@ msgstr ""
318328
">>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]\n"
319329
"['F', 'A', 'C', 'C', 'B', 'A', 'A']"
320330

321-
#: ../../library/bisect.rst:203
331+
#: ../../library/bisect.rst:213
322332
msgid ""
323333
"The :py:func:`~bisect.bisect` and :py:func:`~bisect.insort` functions also "
324334
"work with lists of tuples. The *key* argument can serve to extract the "
@@ -328,7 +338,7 @@ msgstr ""
328338
"tuples(元組)的 lists,*key* 引數可被用以取出在數值表中作為排序依據的欄"
329339
"位: ::"
330340

331-
#: ../../library/bisect.rst:207
341+
#: ../../library/bisect.rst:217
332342
msgid ""
333343
">>> from collections import namedtuple\n"
334344
">>> from operator import attrgetter\n"
@@ -361,15 +371,15 @@ msgid ""
361371
" Movie(name='Titanic', released=1997, director='Cameron')]"
362372
msgstr ""
363373

364-
#: ../../library/bisect.rst:237
374+
#: ../../library/bisect.rst:247
365375
msgid ""
366376
"If the key function is expensive, it is possible to avoid repeated function "
367377
"calls by searching a list of precomputed keys to find the index of a record::"
368378
msgstr ""
369379
"如果鍵函式會消耗較多運算資源,那可以在預先計算好的鍵列表中搜尋該紀錄的索引"
370380
"值,以減少重複的函式呼叫: ::"
371381

372-
#: ../../library/bisect.rst:240
382+
#: ../../library/bisect.rst:250
373383
msgid ""
374384
">>> data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)]\n"
375385
">>> data.sort(key=lambda r: r[1]) # Or use operator.itemgetter(1).\n"

0 commit comments

Comments
 (0)