@@ -11,7 +11,7 @@ msgid ""
1111msgstr ""
1212"Project-Id-Version :Python 3.12\n "
1313"Report-Msgid-Bugs-To :\n "
14- "POT-Creation-Date :2025-03-21 14:55 +0000\n "
14+ "POT-Creation-Date :2025-03-28 14:58 +0000\n "
1515"PO-Revision-Date :2024-05-11 00:32+0000\n "
1616"Last-Translator :Rafael Fontenelle <rffontenelle@gmail.com>, 2025\n "
1717"Language-Team :Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -1192,6 +1192,8 @@ msgid ""
11921192":file:`Include/cpython/object.h`. For convenience of reference, this "
11931193"repeats the definition found there:"
11941194msgstr ""
1195+ "针对 :c:type:`PyTypeObject` 的结构定义可以在 :file:`Include/cpython/object.h` 中找到。 "
1196+ "为了方便参考,这里复述了其中的定义:"
11951197
11961198#: ../../c-api/typeobj.rst:481
11971199msgid ""
@@ -1532,7 +1534,7 @@ msgstr ""
15321534msgid ""
15331535"This field should be accessed using the :c:func:`Py_SIZE()` and "
15341536":c:func:`Py_SET_SIZE()` macros."
1535- msgstr ""
1537+ msgstr "该字段应当使用 :c:func:`Py_SIZE()` 和 :c:func:`Py_SET_SIZE()` 宏来访问。 "
15361538
15371539#: ../../c-api/typeobj.rst:571
15381540msgid "PyTypeObject Slots"
@@ -1623,6 +1625,10 @@ msgid ""
16231625":c:member:`!tp_basicsize`. (Exceptions to this rule can be made using "
16241626":c:func:`PyUnstable_Object_GC_NewWithExtraData`.)"
16251627msgstr ""
1628+ "类型可分为两种:实例为固定长度且 :c:member:`!tp_itemsize` 字段值为零的类型;实例为可变长度且 "
1629+ ":c:member:`!tp_itemsize` 字段值不为零的类型。 对于实例为固定长度的类型,所有实例都具有相同的由 "
1630+ ":c:member:`!tp_basicsize` 给出的大小。 (这条规则的例外情况可通过使用 "
1631+ ":c:func:`PyUnstable_Object_GC_NewWithExtraData` 来实现。)"
16261632
16271633#: ../../c-api/typeobj.rst:626
16281634msgid ""
@@ -1631,6 +1637,8 @@ msgid ""
16311637":c:member:`!tp_basicsize` plus N times :c:member:`!tp_itemsize`, where N is "
16321638"the\" length\" of the object."
16331639msgstr ""
1640+ "对于实例为可变长度的类型,其实例必须具有 :c:member:`~PyVarObject.ob_size` 字段,且实例大小为 "
1641+ ":c:member:`!tp_basicsize` 加 N 乘以 :c:member:`!tp_itemsize`,其中 N 为对象的“长度”。"
16341642
16351643#: ../../c-api/typeobj.rst:631
16361644msgid ""
@@ -1642,12 +1650,19 @@ msgid ""
16421650"underlying storage and its size should be acessed using "
16431651":c:func:`PyLong_Export`."
16441652msgstr ""
1653+ ":c:func:`PyObject_NewVar` 等函数接受 N 值作为参数,并将其保存在实例的 "
1654+ ":c:member:`~PyVarObject.ob_size` 字段中。 请注意在此之后 "
1655+ ":c:member:`~PyVarObject.ob_size` 字段可能还有其他用处。 例如,:py:type:`int` "
1656+ "实例会以具体实现所定义的方式来使用 :c:member:`~PyVarObject.ob_size` 的比特位;下层的存储及其大小应当使用 "
1657+ ":c:func:`PyLong_Export` 来访问。"
16451658
16461659#: ../../c-api/typeobj.rst:641
16471660msgid ""
16481661"The :c:member:`~PyVarObject.ob_size` field should be accessed using the "
16491662":c:func:`Py_SIZE()` and :c:func:`Py_SET_SIZE()` macros."
16501663msgstr ""
1664+ ":c:member:`~PyVarObject.ob_size` 字段应当使用 :c:func:`Py_SIZE()` 和 "
1665+ ":c:func:`Py_SET_SIZE()` 宏来访问。"
16511666
16521667#: ../../c-api/typeobj.rst:644
16531668msgid ""
@@ -1658,13 +1673,19 @@ msgid ""
16581673":py:type:`int`, avoid reading lists' :c:member:`!ob_size` directly. Call "
16591674":c:func:`PyList_Size` instead.)"
16601675msgstr ""
1676+ "此外,实例布局中存在 :c:member:`~PyVarObject.ob_size` 字段并不意味着该实例结构体是可变长度的。 "
1677+ "例如,:py:type:`list` 类型实例即为固定长度,虽然其实例具有 :c:member:`~PyVarObject.ob_size` 字段。 "
1678+ "(和 :py:type:`int` 一样,请避免直接读取 list 的 :c:member:`!ob_size`。 要改为调用 "
1679+ ":c:func:`PyList_Size` 函数。)"
16611680
16621681#: ../../c-api/typeobj.rst:651
16631682msgid ""
16641683"The :c:member:`!tp_basicsize` includes size needed for data of the type's "
16651684":c:member:`~PyTypeObject.tp_base`, plus any extra data needed by each "
16661685"instance."
16671686msgstr ""
1687+ ":c:member:`!tp_basicsize` 包括类型的 :c:member:`~PyTypeObject.tp_base` "
1688+ "所需数据大小,加上每个实例所需额外数据的大小。"
16681689
16691690#: ../../c-api/typeobj.rst:655
16701691msgid ""
@@ -1674,6 +1695,9 @@ msgid ""
16741695":c:member:`!tp_basicsize` must be greater than or equal to the base's "
16751696":c:member:`!tp_basicsize`."
16761697msgstr ""
1698+ "设置 :c:member:`!tp_basicsize` 的正确方式是在被用于声明实例布局的结构体上使用 ``sizeof`` 运算符。 "
1699+ "这个结构体必须包括被用于声明基类型的结构体。 换句话说,:c:member:`!tp_basicsize` 必须大于等于基类型的 "
1700+ ":c:member:`!tp_basicsize`。"
16771701
16781702#: ../../c-api/typeobj.rst:661
16791703msgid ""
@@ -1683,22 +1707,27 @@ msgid ""
16831707"defined by the macro :c:macro:`PyObject_HEAD` or "
16841708":c:macro:`PyObject_VAR_HEAD`, respectively."
16851709msgstr ""
1710+ "由于任何类型都是 :py:type:`object` 的子类型,这个结构体必须包括 :c:type:`PyObject` 或 "
1711+ ":c:type:`PyVarObject` (具体取决于 :c:member:`~PyVarObject.ob_size` 是否应当被包括)。 "
1712+ "它们通常是分别由 :c:macro:`PyObject_HEAD` 或 :c:macro:`PyObject_VAR_HEAD` 宏来定义的。"
16861713
16871714#: ../../c-api/typeobj.rst:667
16881715msgid ""
16891716"The basic size does not include the GC header size, as that header is not "
16901717"part of :c:macro:`PyObject_HEAD`."
1691- msgstr ""
1718+ msgstr "基础大小不包括 GC 标头大小,因为该标头不是 :c:macro:`PyObject_HEAD` 的一部分。 "
16921719
16931720#: ../../c-api/typeobj.rst:670
16941721msgid ""
16951722"For cases where struct used to declare the base type is unknown, see "
16961723":c:member:`PyType_Spec.basicsize` and :c:func:`PyType_FromMetaclass`."
16971724msgstr ""
1725+ "对于用于声明基类型的结构体位置未知的情况,请参见 :c:member:`PyType_Spec.basicsize` 和 "
1726+ ":c:func:`PyType_FromMetaclass`。"
16981727
16991728#: ../../c-api/typeobj.rst:673
17001729msgid "Notes about alignment:"
1701- msgstr ""
1730+ msgstr "有关对齐的说明: "
17021731
17031732#: ../../c-api/typeobj.rst:675
17041733msgid ""
@@ -1708,6 +1737,9 @@ msgid ""
17081737"when using compiler extensions like ``__attribute__((packed))``, it is up to"
17091738" you."
17101739msgstr ""
1740+ ":c:member:`!tp_basicsize` 必须是 ``_Alignof(PyObject)`` 的位数。 当如建议的那样在包括了 "
1741+ ":c:macro:`PyObject_HEAD` 的 ``struct`` 上使用 ``sizeof`` 时,编译器会确保这一点。 当没有使用 C "
1742+ "``struct``,或者当使用像 ``__attribute__((packed))`` 这样的编译器扩展时,这将是你的责任。"
17111743
17121744#: ../../c-api/typeobj.rst:680
17131745msgid ""
@@ -1717,13 +1749,18 @@ msgid ""
17171749"``double``, it is your responsibility that both fields are a multiple of "
17181750"``_Alignof(double)``."
17191751msgstr ""
1752+ "如果可变条目需要特定的对齐,则 :c:member:`!tp_basicsize` 和 :c:member:`!tp_itemsize` "
1753+ "必须均为该对齐值的倍数。 举例来说,如果一个类型的可变部分存储了一个 ``double``,你就要负责让这两个字段都是 "
1754+ "``_Alignof(double)`` 的倍数。"
17201755
17211756#: ../../c-api/typeobj.rst:689
17221757msgid ""
17231758"These fields are inherited separately by subtypes. (That is, if the field is"
17241759" set to zero, :c:func:`PyType_Ready` will copy the value from the base type,"
17251760" indicating that the instances do not need additional storage.)"
17261761msgstr ""
1762+ "这些字段是由子类型分别来继承的。 (也就是说,如果字段被设为零,则 :c:func:`PyType_Ready` "
1763+ "将拷贝来自基类型的值,这表示实例不需要额外的存储。)"
17271764
17281765#: ../../c-api/typeobj.rst:694
17291766msgid ""
@@ -1732,6 +1769,8 @@ msgid ""
17321769"different non-zero value in a subtype (though this depends on the "
17331770"implementation of the base type)."
17341771msgstr ""
1772+ "如果基类型有一个非零的 :c:member:`~PyTypeObject.tp_itemsize`,那么在子类型中将 "
1773+ ":c:member:`~PyTypeObject.tp_itemsize` 设置为不同的非零值通常是不安全的(不过这取决于该基类型的具体实现)。"
17351774
17361775#: ../../c-api/typeobj.rst:701
17371776msgid ""