# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# Hengky Kurniawan, 2025
# python-doc bot, 2026
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.15\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-11-19 21:54+0000\n"
"PO-Revision-Date: 2025-09-16 00:00+0000\n"
"Last-Translator: python-doc bot, 2026\n"
"Language-Team: Indonesian (https://app.transifex.com/python-doc/teams/5390/"
"id/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: id\n"
"Plural-Forms: nplurals=1; plural=0;\n"

msgid "Defining extension modules"
msgstr ""

msgid ""
"A C extension for CPython is a shared library (for example, a ``.so`` file "
"on Linux, ``.pyd`` DLL on Windows), which is loadable into the Python "
"process (for example, it is compiled with compatible compiler settings), and "
"which exports an :dfn:`export hook` function (or an old-"
"style :ref:`initialization function <extension-pyinit>`)."
msgstr ""

msgid ""
"To be importable by default (that is, "
"by :py:class:`importlib.machinery.ExtensionFileLoader`), the shared library "
"must be available on :py:attr:`sys.path`, and must be named after the module "
"name plus an extension listed "
"in :py:attr:`importlib.machinery.EXTENSION_SUFFIXES`."
msgstr ""

msgid ""
"Building, packaging and distributing extension modules is best done with "
"third-party tools, and is out of scope of this document. One suitable tool "
"is Setuptools, whose documentation can be found at https://"
"setuptools.pypa.io/en/latest/setuptools.html."
msgstr ""

msgid "Extension export hook"
msgstr ""

msgid ""
"Support for the :samp:`PyModExport_{<name>}` export hook was added in Python "
"3.15. The older way of defining modules is still available: consult either "
"the :ref:`extension-pyinit` section or earlier versions of this "
"documentation if you plan to support earlier Python versions."
msgstr ""

msgid ""
"The export hook must be an exported function with the following signature:"
msgstr ""

msgid ""
"For modules with ASCII-only names, the :ref:`export hook <extension-export-"
"hook>` must be named :samp:`PyModExport_{<name>}`, with ``<name>`` replaced "
"by the module's name."
msgstr ""

msgid ""
"For non-ASCII module names, the export hook must instead be "
"named :samp:`PyModExportU_{<name>}` (note the ``U``), with ``<name>`` "
"encoded using Python's *punycode* encoding with hyphens replaced by "
"underscores. In Python:"
msgstr ""

msgid ""
"def hook_name(name):\n"
"    try:\n"
"        suffix = b'_' + name.encode('ascii')\n"
"    except UnicodeEncodeError:\n"
"        suffix = b'U_' + name.encode('punycode').replace(b'-', b'_')\n"
"    return b'PyModExport' + suffix"
msgstr ""

msgid ""
"The export hook returns an array of :c:type:`PySlot` entries, terminated by "
"an entry with a slot ID of ``0``. These slots describe how the module should "
"be created and initialized."
msgstr ""

msgid ""
"This array must remain valid and constant until interpreter shutdown. "
"Typically, it should use ``static`` storage. Prefer using "
"the :c:macro:`Py_mod_create` and :c:macro:`Py_mod_exec` slots for any "
"dynamic behavior."
msgstr ""

msgid ""
"The export hook may return ``NULL`` with an exception set to signal failure."
msgstr ""

msgid ""
"It is recommended to define the export hook function using a helper macro:"
msgstr ""

msgid "Declare an extension module export hook. This macro:"
msgstr ""

msgid "specifies the :c:expr:`PySlot*` return type,"
msgstr ""

msgid "adds any special linkage declarations required by the platform, and"
msgstr ""

msgid "for C++, declares the function as ``extern \"C\"``."
msgstr ""

msgid "For example, a module called ``spam`` would be defined like this::"
msgstr ""

msgid ""
"PyABIInfo_VAR(abi_info);\n"
"\n"
"static PySlot spam_slots[] = {\n"
"    PySlot_STATIC_DATA(Py_mod_abi, &abi_info),\n"
"    PySlot_STATIC_DATA(Py_mod_name, \"spam\"),\n"
"    PySlot_FUNC(Py_mod_exec, spam_init_function),\n"
"    ...\n"
"    PySlot_END\n"
"};\n"
"\n"
"PyMODEXPORT_FUNC\n"
"PyModExport_spam(void)\n"
"{\n"
"    return spam_slots;\n"
"}"
msgstr ""

msgid ""
"The export hook is typically the only non-\\ ``static`` item defined in the "
"module's C source."
msgstr ""

msgid ""
"The hook should be kept short. If it does more than ``return`` a static "
"array, several caveats apply:"
msgstr ""

msgid ""
"If you need to use any Python C API, it is recommended to "
"call :c:func:`PyABIInfo_Check` first to raise an exception, rather than "
"crash, in common cases of ABI mismatch."
msgstr ""

msgid ""
"Code in the export hook must never rely on the :term:`GIL`: :term:`free-"
"threaded builds <free-threaded build>` of Python can only check "
"the :c:macro:`Py_mod_gil` slot (or the lack of it) after the hook returns,"
msgstr ""

msgid ""
"Similarly, the hook may be called in any subinterpreter, since "
"the :c:macro:`Py_mod_multiple_interpreters` slot (or lack of it) is only "
"checked after the hook returns."
msgstr ""

msgid "For example::"
msgstr "Sebagai contoh::"

msgid ""
"PyMODEXPORT_FUNC\n"
"PyModExport_modulename(void)\n"
"{\n"
"   if (PyABIInfo_Check(&abi_info, \"modulename\") < 0) {\n"
"      /* ABI mismatch. It's not safe to examine the raised exception. */\n"
"      return NULL;\n"
"   }\n"
"\n"
"   /* use Python API (as little as possible); don't rely on GIL */\n"
"\n"
"   return modulename_slots;\n"
"}"
msgstr ""

msgid ""
"It is possible to export multiple modules from a single shared library by "
"defining multiple export hooks. However, importing  them requires a custom "
"importer or suitably named copies/links of the extension file, because "
"Python's import machinery only finds the function corresponding to the "
"filename. See the `Multiple modules in one library <https://peps.python.org/"
"pep-0489/#multiple-modules-in-one-library>`__ section in :pep:`489` for "
"details."
msgstr ""

msgid "Multi-phase initialization"
msgstr ""

msgid "The process of creating an extension module follows several phases:"
msgstr ""

msgid ""
"Python finds and calls the export hook to get information on how to create "
"the module."
msgstr ""

msgid ""
"Before any substantial code is executed, Python can determine which "
"capabilities the module supports, and it can adjust the environment or "
"refuse loading an incompatible extension. Slots "
"like :c:data:`Py_mod_abi`, :c:data:`Py_mod_gil` "
"and :c:data:`Py_mod_multiple_interpreters` influence this step."
msgstr ""

msgid ""
"By default, Python itself then creates the module object -- that is, it does "
"the equivalent of calling :py:meth:`~object.__new__` when creating an "
"object. This step can be overridden using the :c:data:`Py_mod_create` slot."
msgstr ""

msgid ""
"Python sets initial module attributes like :attr:`~module.__package__` "
"and :attr:`~module.__loader__`, and inserts the module object "
"into :py:attr:`sys.modules`."
msgstr ""

msgid ""
"Afterwards, the module object is initialized in an extension-specific way -- "
"the equivalent of :py:meth:`~object.__init__` when creating an object, or of "
"executing top-level code in a Python-language module. The behavior is "
"specified using the :c:data:`Py_mod_exec` slot."
msgstr ""

msgid ""
"This is called *multi-phase initialization* to distinguish it from the "
"legacy (but still supported) :ref:`single-phase initialization <single-phase-"
"initialization>`, where an initialization function returns a fully "
"constructed module."
msgstr ""

msgid "Added support for multi-phase initialization (:pep:`489`)."
msgstr ""

msgid "Multiple module instances"
msgstr ""

msgid ""
"By default, extension modules are not singletons. For example, if "
"the :py:attr:`sys.modules` entry is removed and the module is re-imported, a "
"new module object is created and, typically, populated with fresh method and "
"type objects. The old module is subject to normal garbage collection. This "
"mirrors the behavior of pure-Python modules."
msgstr ""

msgid ""
"Additional module instances may be created in :ref:`sub-interpreters <sub-"
"interpreter-support>` or after Python runtime reinitialization "
"(:c:func:`Py_Finalize` and :c:func:`Py_Initialize`). In these cases, sharing "
"Python objects between module instances would likely cause crashes or "
"undefined behavior."
msgstr ""

msgid ""
"To avoid such issues, each instance of an extension module should be "
"*isolated*: changes to one instance should not implicitly affect the others, "
"and all state owned by the module, including references to Python objects, "
"should be specific to a particular module instance. See :ref:`isolating-"
"extensions-howto` for more details and a practical guide."
msgstr ""

msgid ""
"A simpler way to avoid these issues is :ref:`raising an error on repeated "
"initialization <isolating-extensions-optout>`."
msgstr ""

msgid ""
"All modules are expected to support :ref:`sub-interpreters <sub-interpreter-"
"support>`, or otherwise explicitly signal a lack of support. This is usually "
"achieved by isolation or blocking repeated initialization, as above. A "
"module may also be limited to the main interpreter using "
"the :c:data:`Py_mod_multiple_interpreters` slot."
msgstr ""

msgid "``PyInit`` function"
msgstr ""

msgid ""
"This functionality will not get new features, but there are no plans to "
"remove it."
msgstr ""

msgid ""
"Instead of :c:func:`PyModExport_modulename`, an extension module can define "
"an older-style :dfn:`initialization function` with the signature:"
msgstr ""

msgid ""
"Its name should be :samp:`PyInit_{<name>}`, with ``<name>`` replaced by the "
"name of the module. For non-ASCII module names, use :samp:`PyInitU_{<name>}` "
"instead, with ``<name>`` encoded in the same way as for the :ref:`export "
"hook <extension-export-hook>` (that is, using Punycode with underscores)."
msgstr ""

msgid ""
"If a module exports both :samp:`PyInit_{<name>}` "
"and :samp:`PyModExport_{<name>}`, the :samp:`PyInit_{<name>}` function is "
"ignored."
msgstr ""

msgid ""
"Like with :c:macro:`PyMODEXPORT_FUNC`, it is recommended to define the "
"initialization function using a helper macro:"
msgstr ""

msgid "Declare an extension module initialization function. This macro:"
msgstr ""

msgid "specifies the :c:expr:`PyObject*` return type,"
msgstr ""

msgid ""
"Normally, the initialization function (``PyInit_modulename``) returns "
"a :c:type:`PyModuleDef` instance with non-"
"``NULL`` :c:member:`~PyModuleDef.m_slots`. This allows Python to "
"use :ref:`multi-phase initialization <multi-phase-initialization>`."
msgstr ""

msgid ""
"Before it is returned, the ``PyModuleDef`` instance must be initialized "
"using the following function:"
msgstr ""

msgid ""
"Ensure a module definition is a properly initialized Python object that "
"correctly reports its type and a reference count."
msgstr ""

msgid "Return *def* cast to ``PyObject*``, or ``NULL`` if an error occurred."
msgstr ""

msgid ""
"Calling this function is required before returning a :c:type:`PyModuleDef` "
"from a module initialization function. It should not be used in other "
"contexts."
msgstr ""

msgid ""
"Note that Python assumes that ``PyModuleDef`` structures are statically "
"allocated. This function may return either a new reference or a borrowed "
"one; this reference must not be released."
msgstr ""

msgid ""
"static struct PyModuleDef spam_module = {\n"
"    .m_base = PyModuleDef_HEAD_INIT,\n"
"    .m_name = \"spam\",\n"
"    ...\n"
"};\n"
"\n"
"PyMODINIT_FUNC\n"
"PyInit_spam(void)\n"
"{\n"
"    return PyModuleDef_Init(&spam_module);\n"
"}"
msgstr ""
"static struct PyModuleDef spam_module = {\n"
"    .m_base = PyModuleDef_HEAD_INIT,\n"
"    .m_name = \"spam\",\n"
"    ...\n"
"};\n"
"\n"
"PyMODINIT_FUNC\n"
"PyInit_spam(void)\n"
"{\n"
"    return PyModuleDef_Init(&spam_module);\n"
"}"

msgid "Legacy single-phase initialization"
msgstr ""

msgid ""
"Single-phase initialization is a legacy mechanism to initialize extension "
"modules, with known drawbacks and design flaws. Extension module authors are "
"encouraged to use multi-phase initialization instead."
msgstr ""

msgid "However, there are no plans to remove support for it."
msgstr ""

msgid ""
"In single-phase initialization, the old-style :ref:`initialization function "
"<extension-pyinit>` (``PyInit_modulename``) should create, populate and "
"return a module object. This is typically done "
"using :c:func:`PyModule_Create` and functions "
"like :c:func:`PyModule_AddObjectRef`."
msgstr ""

msgid ""
"Single-phase initialization differs from the :ref:`default <multi-phase-"
"initialization>` in the following ways:"
msgstr ""

msgid ""
"Single-phase modules with :c:member:`PyModuleDef.m_size` set to -1 are, or "
"rather *contain*, “singletons”."
msgstr ""

msgid ""
"When such a module is first initialized, Python saves the contents of the "
"module's ``__dict__`` (that is, typically, the module's functions and types)."
msgstr ""

msgid ""
"For subsequent imports, Python does not call the initialization function "
"again. Instead, it creates a new module object with a new ``__dict__``, and "
"copies the saved contents to it. Modules are matched to the saved contents "
"by a (*module_name*, *file_name*) tuple where:"
msgstr ""

msgid ""
"*module_name* is the module's full dotted name, taken "
"from :py:attr:`ModuleSpec.name <importlib.machinery.ModuleSpec.name>` (or "
"the equivalent argument of the importing function). Note that names that the "
"initialization function uses to create the module (for "
"example, :c:member:`PyModuleDef.m_name`) are not taken into account."
msgstr ""

msgid ""
"*file_name* is the extension's file name. It is unset for modules not loaded "
"from a file, such as built-ins and modules added "
"with :c:func:`PyImport_CreateModuleFromInitfunc` "
"or :c:func:`PyImport_AppendInittab`."
msgstr ""

msgid ""
"As part of the first initialization, Python also adds the module "
"to :data:`sys.modules` under its name. For example, given a single-phase "
"module ``_testsinglephase`` [#testsinglephase]_ that defines a function "
"``sum`` and an exception class ``error``:"
msgstr ""

msgid ""
">>> import sys\n"
">>> import _testsinglephase as one\n"
">>> del sys.modules['_testsinglephase']\n"
">>> import _testsinglephase as two\n"
">>> one is two\n"
"False\n"
">>> one.__dict__ is two.__dict__\n"
"False\n"
">>> one.sum is two.sum\n"
"True\n"
">>> one.error is two.error\n"
"True"
msgstr ""
">>> import sys\n"
">>> import _testsinglephase as one\n"
">>> del sys.modules['_testsinglephase']\n"
">>> import _testsinglephase as two\n"
">>> one is two\n"
"False\n"
">>> one.__dict__ is two.__dict__\n"
"False\n"
">>> one.sum is two.sum\n"
"True\n"
">>> one.error is two.error\n"
"True"

msgid ""
"The exact behavior should be considered a CPython implementation detail."
msgstr ""

msgid ""
"For single-phase modules with non-negative :c:member:`PyModuleDef.m_size`, "
"Python may cache a pointer to the initialization function under the "
"(*module_name*, *file_name*) key as for ``m_size == -1``."
msgstr ""

msgid ""
"Subsequent imports that specify a different initialization function (for "
"example, using :c:func:`PyImport_CreateModuleFromInitfunc`) may call either "
"the cached function or the provided \"new\" one."
msgstr ""

msgid ""
"The exact behavior should again be considered a CPython implementation "
"detail."
msgstr ""

msgid ""
"To work around the fact that ``PyInit_modulename`` does not take a *spec* "
"argument, some state of the import machinery is saved and applied to the "
"first suitable module created during the ``PyInit_modulename`` call. "
"Specifically, when a sub-module is imported, this mechanism prepends the "
"parent package name to the name of the module."
msgstr ""

msgid ""
"A single-phase ``PyInit_modulename`` function should create “its” module "
"object as soon as possible, before any other module objects can be created."
msgstr ""

msgid "Non-ASCII module names (``PyInitU_modulename``) are not supported."
msgstr ""

msgid ""
"Single-phase modules support module lookup functions "
"like :c:func:`PyState_FindModule`."
msgstr ""

msgid "The module's :c:member:`PyModuleDef.m_slots` must be NULL."
msgstr ""

msgid ""
"``_testsinglephase`` is an internal module used in CPython's self-test "
"suite; your installation may or may not include it."
msgstr ""
