# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2022, Python Software Foundation
# This file is distributed under the same license as the Python package.
#
# Translators:
# , 2016
# Liang-Bo Wang , 2017
# pertertc , 2022
# Matt Wang , 2022
msgid ""
msgstr ""
"Project-Id-Version: Python 3.12\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-17 17:39+0800\n"
"PO-Revision-Date: 2023-08-01 12:53+0800\n"
"Last-Translator: Matt Wang \n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Poedit 3.3.2\n"
#: ../../library/bisect.rst:2
msgid ":mod:`bisect` --- Array bisection algorithm"
msgstr ":mod:`bisect` --- (Array bisection algorithm)"
#: ../../library/bisect.rst:10
msgid "**Source code:** :source:`Lib/bisect.py`"
msgstr "****\\ :source:`Lib/bisect.py`"
#: ../../library/bisect.rst:14
msgid ""
"This module provides support for maintaining a list in sorted order without "
"having to sort the list after each insertion. For long lists of items with "
"expensive comparison operations, this can be an improvement over linear "
"searches or frequent resorting."
msgstr ""
" list "
"list list "
""
#: ../../library/bisect.rst:19
msgid ""
"The module is called :mod:`bisect` because it uses a basic bisection "
"algorithm to do its work. Unlike other bisection tools that search for a "
"specific value, the functions in this module are designed to locate an "
"insertion point. Accordingly, the functions never call an :meth:`__eq__` "
"method to determine whether a value has been found. Instead, the functions "
"only call the :meth:`__lt__` method and will return an insertion point "
"between values in an array."
msgstr ""
" :mod:`bisect` "
""
" :meth:`__eq__` :meth:"
"`__lt__` "
#: ../../library/bisect.rst:29
msgid "The following functions are provided:"
msgstr ""
#: ../../library/bisect.rst:34
msgid ""
"Locate the insertion point for *x* in *a* to maintain sorted order. The "
"parameters *lo* and *hi* may be used to specify a subset of the list which "
"should be considered; by default the entire list is used. If *x* is already "
"present in *a*, the insertion point will be before (to the left of) any "
"existing entries. The return value is suitable for use as the first "
"parameter to ``list.insert()`` assuming that *a* is already sorted."
msgstr ""
" *a* *x* *a* *lo* *hi* "
" list list *a* "
" *x* *x* ``list."
"insert()`` *a* "
#: ../../library/bisect.rst:41
msgid ""
"The returned insertion point *ip* partitions the array *a* into two slices "
"such that ``all(elem < x for elem in a[lo : ip])`` is true for the left "
"slice and ``all(elem >= x for elem in a[ip : hi])`` is true for the right "
"slice."
msgstr ""
" *ip* *a* "
"``all(elem < x for elem in a[lo : ip])`` ``all(elem >= "
"x for elem in a[ip : hi])`` "
#: ../../library/bisect.rst:46
msgid ""
"*key* specifies a :term:`key function` of one argument that is used to "
"extract a comparison key from each element in the array. To support "
"searching complex records, the key function is not applied to the *x* value."
msgstr ""
"*key* :term:`key function` function "
" function "
" *x*"
#: ../../library/bisect.rst:50
msgid ""
"If *key* is ``None``, the elements are compared directly and no key function "
"is called."
msgstr " *key* ``None``"
#: ../../library/bisect.rst:53 ../../library/bisect.rst:67
#: ../../library/bisect.rst:85 ../../library/bisect.rst:105
msgid "Added the *key* parameter."
msgstr " *key* "
#: ../../library/bisect.rst:60
msgid ""
"Similar to :py:func:`~bisect.bisect_left`, but returns an insertion point "
"which comes after (to the right of) any existing entries of *x* in *a*."
msgstr ""
" :py:func:`~bisect.bisect_left` *a* *x* "
""
#: ../../library/bisect.rst:63
msgid ""
"The returned insertion point *ip* partitions the array *a* into two slices "
"such that ``all(elem x for elem in a[ip : hi])`` is true for the right "
"slice."
msgstr ""
" *ip* *a* "
"``all(elem "
"x for elem in a[ip : hi])`` "
#: ../../library/bisect.rst:73
msgid "Insert *x* in *a* in sorted order."
msgstr " *x* list *a*"
#: ../../library/bisect.rst:75
msgid ""
"This function first runs :py:func:`~bisect.bisect_left` to locate an "
"insertion point. Next, it runs the :meth:`insert` method on *a* to insert "
"*x* at the appropriate position to maintain sort order."
msgstr ""
" :py:func:`~bisect.bisect_left` :meth:"
"`insert` *a* *x* "
#: ../../library/bisect.rst:79 ../../library/bisect.rst:99
msgid ""
"To support inserting records in a table, the *key* function (if any) is "
"applied to *x* for the search step but not for the insertion step."
msgstr " *key* "
#: ../../library/bisect.rst:82 ../../library/bisect.rst:102
msgid ""
"Keep in mind that the ``O(log n)`` search is dominated by the slow O(n) "
"insertion step."
msgstr ""
" ``O(log n)`` O(n) O(n)"
#: ../../library/bisect.rst:92
msgid ""
"Similar to :py:func:`~bisect.insort_left`, but inserting *x* in *a* after "
"any existing entries of *x*."
msgstr ""
" :py:func:`~bisect.insort_left` *a* *x* "
""
#: ../../library/bisect.rst:95
msgid ""
"This function first runs :py:func:`~bisect.bisect_right` to locate an "
"insertion point. Next, it runs the :meth:`insert` method on *a* to insert "
"*x* at the appropriate position to maintain sort order."
msgstr ""
" :py:func:`~bisect.bisect_right` :meth:"
"`insert` *a* *x* "
#: ../../library/bisect.rst:110
msgid "Performance Notes"
msgstr ""
#: ../../library/bisect.rst:112
msgid ""
"When writing time sensitive code using *bisect()* and *insort()*, keep these "
"thoughts in mind:"
msgstr ""
" *bisect()* *insort()*"
""
#: ../../library/bisect.rst:115
msgid ""
"Bisection is effective for searching ranges of values. For locating specific "
"values, dictionaries are more performant."
msgstr ""
""
""
#: ../../library/bisect.rst:118
msgid ""
"The *insort()* functions are ``O(n)`` because the logarithmic search step is "
"dominated by the linear time insertion step."
msgstr ""
"*insort()* ``O(n)`` "
"(dominate)"
#: ../../library/bisect.rst:121
msgid ""
"The search functions are stateless and discard key function results after "
"they are used. Consequently, if the search functions are used in a loop, "
"the key function may be called again and again on the same array elements. "
"If the key function isn't fast, consider wrapping it with :py:func:"
"`functools.cache` to avoid duplicate computations. Alternatively, consider "
"searching an array of precomputed keys to locate the insertion point (as "
"shown in the examples section below)."
msgstr ""
" (stateless)"
" list "
" :py:func:`functools.cache` "
" (array of precomputed keys) "
""
#: ../../library/bisect.rst:131
msgid ""
"`Sorted Collections `_ is a "
"high performance module that uses *bisect* to managed sorted collections of "
"data."
msgstr ""
"` (Sorted Collections) `_ *bisect* "
#: ../../library/bisect.rst:135
msgid ""
"The `SortedCollection recipe `_ uses bisect to build a full-featured collection class "
"with straight-forward search methods and support for a key-function. The "
"keys are precomputed to save unnecessary calls to the key function during "
"searches."
msgstr ""
"`SortedCollection recipe `_ (collection "
"class) (search methods) "
""
#: ../../library/bisect.rst:143
msgid "Searching Sorted Lists"
msgstr " list"
#: ../../library/bisect.rst:145
msgid ""
"The above `bisect functions`_ are useful for finding insertion points but "
"can be tricky or awkward to use for common searching tasks. The following "
"five functions show how to transform them into the standard lookups for "
"sorted lists::"
msgstr ""
" `bisect functions`_ "
"\n"
"\n"
"::"
#: ../../library/bisect.rst:187
msgid "Examples"
msgstr ""
#: ../../library/bisect.rst:191
msgid ""
"The :py:func:`~bisect.bisect` function can be useful for numeric table "
"lookups. This example uses :py:func:`~bisect.bisect` to look up a letter "
"grade for an exam score (say) based on a set of ordered numeric breakpoints: "
"90 and up is an 'A', 80 to 89 is a 'B', and so on::"
msgstr ""
":py:func:`~bisect.bisect` (numeric table lookup)"
" :py:func:`~bisect.bisect` "
"90 'A'80 89 'B'\n"
"\n"
"::"
#: ../../library/bisect.rst:203
msgid ""
"The :py:func:`~bisect.bisect` and :py:func:`~bisect.insort` functions also "
"work with lists of tuples. The *key* argument can serve to extract the "
"field used for ordering records in a table::"
msgstr ""
":py:func:`~bisect.bisect` :py:func:`~bisect.insort` "
"tuples lists*key* "
"\n"
"\n"
"::"
#: ../../library/bisect.rst:237
msgid ""
"If the key function is expensive, it is possible to avoid repeated function "
"calls by searching a list of precomputed keys to find the index of a record::"
msgstr ""
""
"\n"
"\n"
"::"