@@ -1478,6 +1478,14 @@ msgid ""
14781478"for the list type has fixed-length instances, yet those instances have a "
14791479"meaningful :c:member:`~PyVarObject.ob_size` field)."
14801480msgstr ""
1481+ "对于具有可变长度实例的类型,实例必须有一个 :c:member:`~PyVarObject.ob_size` 字段,实例大小为 "
1482+ ":c:member:`~PyTypeObject.tp_basicsize` 加上 N 乘以 "
1483+ ":c:member:`~PyTypeObject.tp_itemsize`,其中 N 是对象的“长度”。 N 的值通常存储在实例的 "
1484+ ":c:member:`~PyVarObject.ob_size` 字段中。 但也有例外:举例来说,整数类型使用负的 "
1485+ ":c:member:`~PyVarObject.ob_size` 来表示负数,N 在这里就是 ``abs(ob_size)``。 此外,在实例布局中存在"
1486+ " :c:member:`~PyVarObject.ob_size` "
1487+ "字段并不意味着实例结构是可变长度的(例如,列表类型的结构体有固定长度的实例,但这些实例却包含一个有意义的 "
1488+ ":c:member:`~PyVarObject.ob_size` 字段)。"
14811489
14821490#: ../../c-api/typeobj.rst:632
14831491msgid ""
@@ -1490,6 +1498,11 @@ msgid ""
14901498"``sizeof`` operator on the struct used to declare the instance layout. The "
14911499"basic size does not include the GC header size."
14921500msgstr ""
1501+ "基本大小包括由宏 :c:macro:`PyObject_HEAD` 或 :c:macro:`PyObject_VAR_HEAD` "
1502+ "(以用于声明实例结构的宏为准)声明的实例中的字段,如果存在 :c:member:`~PyObject._ob_prev` 和 "
1503+ ":c:member:`~PyObject._ob_next` 字段则将相应地包括这些字段。 这意味着为 "
1504+ ":c:member:`~PyTypeObject.tp_basicsize` 获取初始化器的唯一正确方式是在用于声明实例布局的结构上使用 "
1505+ "``sizeof`` 操作符。 基本大小不包括 GC 标头的大小。"
14931506
14941507#: ../../c-api/typeobj.rst:640
14951508msgid ""
@@ -1501,12 +1514,16 @@ msgid ""
15011514":c:member:`~PyTypeObject.tp_basicsize` is a multiple of ``sizeof(double)`` "
15021515"(assuming this is the alignment requirement for ``double``)."
15031516msgstr ""
1517+ "关于对齐的说明:如果变量条目需要特定的对齐,则应通过 :c:member:`~PyTypeObject.tp_basicsize` 的值来处理。 "
1518+ "例如:假设某个类型实现了一个 ``double`` 数组。 :c:member:`~PyTypeObject.tp_itemsize` 就是 "
1519+ "``sizeof(double)``。 程序员有责任确保 :c:member:`~PyTypeObject.tp_basicsize` 是 "
1520+ "``sizeof(double)`` 的倍数(假设这是 ``double`` 的对齐要求)。"
15041521
15051522#: ../../c-api/typeobj.rst:647
15061523msgid ""
15071524"For any type with variable-length instances, this field must not be "
15081525"``NULL``."
1509- msgstr ""
1526+ msgstr "对于任何具有可变长度实例的类型,该字段不可为 ``NULL``。 "
15101527
15111528#: ../../c-api/typeobj.rst:651
15121529msgid ""
@@ -1515,6 +1532,8 @@ msgid ""
15151532"set :c:member:`~PyTypeObject.tp_itemsize` to a different non-zero value in a"
15161533" subtype (though this depends on the implementation of the base type)."
15171534msgstr ""
1535+ "这些字段将由子类分别继承。 如果基本类型有一个非零的 :c:member:`~PyTypeObject.tp_itemsize`,那么在子类型中将 "
1536+ ":c:member:`~PyTypeObject.tp_itemsize` 设置为不同的非零值通常是不安全的(不过这取决于该基本类型的具体实现)。"
15181537
15191538#: ../../c-api/typeobj.rst:659
15201539msgid ""
0 commit comments