Expand Up @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date:2024-09-24 07:20 +0000\n" "POT-Creation-Date:2025-07-21 00:18 +0000\n" "PO-Revision-Date: 2018-05-23 14:06+0000\n" "Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" Expand Down Expand Up @@ -587,19 +587,19 @@ msgid "" "following fields:" msgstr "" #: ../../c-api/memory.rst:423 ../../c-api/memory.rst:670 #: ../../c-api/memory.rst:423 ../../c-api/memory.rst:674 msgid "Field" msgstr "欄位" #: ../../c-api/memory.rst:423 ../../c-api/memory.rst:670 #: ../../c-api/memory.rst:423 ../../c-api/memory.rst:674 msgid "Meaning" msgstr "意義" #: ../../c-api/memory.rst:425 ../../c-api/memory.rst:672 #: ../../c-api/memory.rst:425 ../../c-api/memory.rst:676 msgid "``void *ctx``" msgstr "``void *ctx``" #: ../../c-api/memory.rst:425 ../../c-api/memory.rst:672 #: ../../c-api/memory.rst:425 ../../c-api/memory.rst:676 msgid "user context passed as first argument" msgstr "" Expand Down Expand Up @@ -1003,92 +1003,99 @@ msgid "" "envvar:`PYTHONMALLOC` environment variable (ex: ``PYTHONMALLOC=malloc``)." msgstr "" #: ../../c-api/memory.rst:660 #: ../../c-api/memory.rst:659 msgid "" "Typically, it makes sense to disable the pymalloc allocator when building " "Python with AddressSanitizer (:option:`--with-address-sanitizer`) which " "helps uncover low level bugs within the C code." msgstr "" #: ../../c-api/memory.rst:664 msgid "Customize pymalloc Arena Allocator" msgstr "" #: ../../c-api/memory.rst:666 #: ../../c-api/memory.rst:670 msgid "" "Structure used to describe an arena allocator. The structure has three " "fields:" msgstr "" #: ../../c-api/memory.rst:674 #: ../../c-api/memory.rst:678 msgid "``void* alloc(void *ctx, size_t size)``" msgstr "``void* alloc(void *ctx, size_t size)``" #: ../../c-api/memory.rst:674 #: ../../c-api/memory.rst:678 msgid "allocate an arena of size bytes" msgstr "" #: ../../c-api/memory.rst:676 #: ../../c-api/memory.rst:680 msgid "``void free(void *ctx, void *ptr, size_t size)``" msgstr "``void free(void *ctx, void *ptr, size_t size)``" #: ../../c-api/memory.rst:676 #: ../../c-api/memory.rst:680 msgid "free an arena" msgstr "" #: ../../c-api/memory.rst:681 #: ../../c-api/memory.rst:685 msgid "Get the arena allocator." msgstr "" #: ../../c-api/memory.rst:685 #: ../../c-api/memory.rst:689 msgid "Set the arena allocator." msgstr "" #: ../../c-api/memory.rst:690 #: ../../c-api/memory.rst:694 msgid "The mimalloc allocator" msgstr "" #: ../../c-api/memory.rst:694 #: ../../c-api/memory.rst:698 msgid "" "Python supports the mimalloc allocator when the underlying platform support " "is available. mimalloc \"is a general purpose allocator with excellent " "performance characteristics. Initially developed by Daan Leijen for the " "runtime systems of the Koka and Lean languages.\"" msgstr "" #: ../../c-api/memory.rst:699 #: ../../c-api/memory.rst:703 msgid "tracemalloc C API" msgstr "" #: ../../c-api/memory.rst:705 #: ../../c-api/memory.rst:709 msgid "Track an allocated memory block in the :mod:`tracemalloc` module." msgstr "" #: ../../c-api/memory.rst:707 #: ../../c-api/memory.rst:711 msgid "" "Return ``0`` on success, return ``-1`` on error (failed to allocate memory " "to store the trace). Return ``-2`` if tracemalloc is disabled." msgstr "" #: ../../c-api/memory.rst:710 #: ../../c-api/memory.rst:714 msgid "If memory block is already tracked, update the existing trace." msgstr "" #: ../../c-api/memory.rst:714 #: ../../c-api/memory.rst:718 msgid "" "Untrack an allocated memory block in the :mod:`tracemalloc` module. Do " "nothing if the block was not tracked." msgstr "" #: ../../c-api/memory.rst:717 #: ../../c-api/memory.rst:721 msgid "Return ``-2`` if tracemalloc is disabled, otherwise return ``0``." msgstr "" #: ../../c-api/memory.rst:723 #: ../../c-api/memory.rst:727 msgid "Examples" msgstr "範例" #: ../../c-api/memory.rst:725 #: ../../c-api/memory.rst:729 msgid "" "Here is the example from section :ref:`memoryoverview`, rewritten so that " "the I/O buffer is allocated from the Python heap by using the first function " "set::" msgstr "" #: ../../c-api/memory.rst:728 #: ../../c-api/memory.rst:732 msgid "" "PyObject *res;\n" "char *buf = (char *) PyMem_Malloc(BUFSIZ); /* for I/O */\n" Expand All @@ -1101,11 +1108,11 @@ msgid "" "return res;" msgstr "" #: ../../c-api/memory.rst:738 #: ../../c-api/memory.rst:742 msgid "The same code using the type-oriented function set::" msgstr "" #: ../../c-api/memory.rst:740 #: ../../c-api/memory.rst:744 msgid "" "PyObject *res;\n" "char *buf = PyMem_New(char, BUFSIZ); /* for I/O */\n" Expand All @@ -1118,7 +1125,7 @@ msgid "" "return res;" msgstr "" #: ../../c-api/memory.rst:750 #: ../../c-api/memory.rst:754 msgid "" "Note that in the two examples above, the buffer is always manipulated via " "functions belonging to the same set. Indeed, it is required to use the same " Expand All @@ -1128,7 +1135,7 @@ msgid "" "different allocators operating on different heaps. ::" msgstr "" #: ../../c-api/memory.rst:757 #: ../../c-api/memory.rst:761 msgid "" "char *buf1 = PyMem_New(char, BUFSIZ);\n" "char *buf2 = (char *) malloc(BUFSIZ);\n" Expand All @@ -1139,14 +1146,14 @@ msgid "" "free(buf1); /* Fatal -- should be PyMem_Del() */" msgstr "" #: ../../c-api/memory.rst:765 #: ../../c-api/memory.rst:769 msgid "" "In addition to the functions aimed at handling raw memory blocks from the " "Python heap, objects in Python are allocated and released with :c:macro:" "`PyObject_New`, :c:macro:`PyObject_NewVar` and :c:func:`PyObject_Del`." msgstr "" #: ../../c-api/memory.rst:769 #: ../../c-api/memory.rst:773 msgid "" "These will be explained in the next chapter on defining and implementing new " "object types in C." Expand Down