Skip to content
Draft
Changes from 1 commit
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
Prev Previous commit
feat: to: /import.rst:676
- rst:668 的 key-off 實際的意思可以討論
  • Loading branch information
ken71301 committed Dec 23, 2024
commit 459bda305441c957d3d38df96bccdceff8247949
44 changes: 41 additions & 3 deletions reference/import.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgstr ""
"Project-Id-Version: Python 3.13\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-03 11:11+0800\n"
"PO-Revision-Date: 2024-12-11 22:16+0800\n"
"PO-Revision-Date: 2024-12-23 15:33+0800\n"
"Last-Translator: Ken Cheng <[email protected]>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
Expand Down Expand Up @@ -1124,7 +1124,7 @@ msgstr ""

#: ../../reference/import.rst:608
msgid "Cached bytecode invalidation"
msgstr ""
msgstr "被快取的位元組碼的無效化"

#: ../../reference/import.rst:610
msgid ""
Expand All @@ -1135,6 +1135,10 @@ msgid ""
"cache file by checking the stored metadata in the cache file against the "
"source's metadata."
msgstr ""
"在 Python 從 ``.pyc`` 檔案載入被快取的位元組碼之前,會檢查該快取是否與來源的 "
"``.py`` 檔案保持同步。預設情況下,Python 透過在寫入快取檔案時儲存來源檔案的最"
"後修改時間戳和大小來完成此操作。在執行時,引入系統會透過將快取檔案中儲存的元"
"資料 (metadata) 與來源檔案的元資料進行比對來驗證快取檔案。"

#: ../../reference/import.rst:617
msgid ""
Expand All @@ -1149,16 +1153,25 @@ msgid ""
"Hash-based ``.pyc`` files validation behavior may be overridden with the :"
"option:`--check-hash-based-pycs` flag."
msgstr ""
"Python 還支援「基於雜湊」的快取檔案,這些檔案儲存來源檔案內容的雜湊值,而不是"
"其元資料。基於雜湊的 ``.pyc`` 檔案有兩種變體:需檢查和不需要檢查的。對於需檢"
"查的基於雜湊的 ``.pyc`` 檔案,Python 透過對來源檔案進行雜湊並將結果與快取檔案"
"中的雜湊進行比較來驗證快取檔案。如果發現需檢查的基於雜湊的快取檔案無效,"
"Python 會重新產生並寫入新的需檢查的基於雜湊的快取檔案。對於不需要檢查的基於雜"
"湊的 ``.pyc`` 檔案,只要檔案存在,Python 就假設快取檔案是有效的。可以使用 :"
"option:`--check-hash-based-pycs` 旗標覆蓋基於雜湊的 ``.pyc`` 檔案的驗證行為。"

#: ../../reference/import.rst:628
msgid ""
"Added hash-based ``.pyc`` files. Previously, Python only supported timestamp-"
"based invalidation of bytecode caches."
msgstr ""
"新增了基於雜湊的 ``.pyc`` 檔案。此前,Python 只支援基於時間戳的位元組碼快取無"
"效化。"

#: ../../reference/import.rst:634
msgid "The Path Based Finder"
msgstr ""
msgstr "基於路徑的尋檢器"

#: ../../reference/import.rst:639
msgid ""
Expand All @@ -1168,13 +1181,19 @@ msgid ""
"contains a list of :term:`path entries <path entry>`. Each path entry names "
"a location to search for modules."
msgstr ""
"如前所述,Python 附帶了幾個預設的元路徑尋檢器。其中之一稱為 :term:`path "
"based finder`\\ (\\ :class:`~importlib.machinery.PathFinder`\\ ),它搜尋 :"
"term:`import path`,該路徑包含一個 :term:`路徑條目 <path entry>` 的串列。每個"
"路徑條目都指定了一個用於搜尋模組的位置。"

#: ../../reference/import.rst:645
msgid ""
"The path based finder itself doesn't know how to import anything. Instead, "
"it traverses the individual path entries, associating each of them with a "
"path entry finder that knows how to handle that particular kind of path."
msgstr ""
"基於路徑的尋檢器本身並不知道如何引入任何東西。相反,它遍歷各個路徑條目,並將"
"每個路徑條目與一個知道如何處理該特定路徑類型的路徑條目尋檢器關聯起來。"

#: ../../reference/import.rst:649
msgid ""
Expand All @@ -1186,13 +1205,20 @@ msgid ""
"also handle loading all of these file types (other than shared libraries) "
"from zipfiles."
msgstr ""
"預設的一組路徑條目尋檢器實作了在檔案系統中尋找模組的所有語意,包括處理特殊檔"
"案類型,例如 Python 原始程式碼檔案(``.py`` 檔案)、Python 位元組程式碼檔案"
"(``.pyc`` 檔案)以及共享函式庫(例如 ``.so`` 檔案)。當標準函式庫中的 :mod:"
"`zipimport` 模組支援時,預設的路徑條目尋檢器也能處理從壓縮檔案中載入這些檔案"
"類型(共享函式庫除外)。"

#: ../../reference/import.rst:656
msgid ""
"Path entries need not be limited to file system locations. They can refer "
"to URLs, database queries, or any other location that can be specified as a "
"string."
msgstr ""
"路徑條目不必侷限於檔案系統位置。它們可以參照 URL、資料庫查詢或任何可以作為字"
"串指定的位置。"

#: ../../reference/import.rst:660
msgid ""
Expand All @@ -1204,6 +1230,10 @@ msgid ""
"protocol described below, which was then used to get a loader for the module "
"from the web."
msgstr ""
"基於路徑的尋檢器提供了額外的掛鉤和協定,讓你可以擴展和自定可搜尋的路徑條目類"
"型。例如,如果你希望支援將路徑條目作為網路 URLs,你可以撰寫一個實作 HTTP 語意"
"的掛鉤,用於在網路上尋找模組。這個掛鉤(一個可呼叫物件)會回傳一個支援下述協"
"定的 :term:`path entry finder` ,該尋檢器隨後用於從網路中獲取模組的載入器。"

#: ../../reference/import.rst:668
msgid ""
Expand All @@ -1215,6 +1245,11 @@ msgid ""
"In particular, meta path finders operate at the beginning of the import "
"process, as keyed off the :data:`sys.meta_path` traversal."
msgstr ""
"提醒一句:本節與前一節都使用了 *尋檢器* 這個術語,並透過使用術語 :term:`meta "
"path finder` 和 :term:`path entry finder` 來區分它們。這兩種類型的尋檢器非常"
"相似,支援類似的協定,並在引入過程中以類似的方式運作,但請記住,它們之間有些"
"微的差異。特別是,元路徑尋檢器在引入過程的一開始運作,並通過 :data:`sys."
"meta_path` 的遍歷關閉 (key off)。"

#: ../../reference/import.rst:676
msgid ""
Expand All @@ -1223,6 +1258,9 @@ msgid ""
"removed from :data:`sys.meta_path`, none of the path entry finder semantics "
"would be invoked."
msgstr ""
"相比之下,路徑條目尋檢器在某種意義上是基於路徑的尋檢器的一個實作細節。事實"
"上,如果基於路徑的尋檢器從 :data:`sys.meta_path` 中移除,路徑條目尋檢器的任何"
"語意都不會被調用。"

#: ../../reference/import.rst:683
msgid "Path entry finders"
Expand Down