@@ -1605,6 +1605,10 @@ msgid ""
1605
1605
":c:member:`!tp_basicsize`. (Exceptions to this rule can be made using "
1606
1606
":c:func:`PyUnstable_Object_GC_NewWithExtraData`.)"
1607
1607
msgstr ""
1608
+ "类型可分为两种:实例为固定长度且 :c:member:`!tp_itemsize` 字段值为零的类型;实例为可变长度且 "
1609
+ ":c:member:`!tp_itemsize` 字段值不为零的类型。 对于实例为固定长度的类型,所有实例都具有相同的由 "
1610
+ ":c:member:`!tp_basicsize` 给出的大小。 (这条规则的例外情况可通过使用 "
1611
+ ":c:func:`PyUnstable_Object_GC_NewWithExtraData` 来实现。)"
1608
1612
1609
1613
#: ../../c-api/typeobj.rst:604
1610
1614
msgid ""
@@ -1613,6 +1617,8 @@ msgid ""
1613
1617
":c:member:`!tp_basicsize` plus N times :c:member:`!tp_itemsize`, where N is "
1614
1618
"the \" length\" of the object."
1615
1619
msgstr ""
1620
+ "对于实例为可变长度的类型,其实例必须具有 :c:member:`~PyVarObject.ob_size` 字段,且实例大小为 "
1621
+ ":c:member:`!tp_basicsize` 加 N 乘以 :c:member:`!tp_itemsize`,其中 N 为对象的“长度”。"
1616
1622
1617
1623
#: ../../c-api/typeobj.rst:609
1618
1624
msgid ""
@@ -1624,12 +1630,19 @@ msgid ""
1624
1630
"underlying storage and its size should be acessed using "
1625
1631
":c:func:`PyLong_Expo
8000
rt`."
1626
1632
msgstr ""
1633
+ ":c:func:`PyObject_NewVar` 等函数接受 N 值作为参数,并将其保存在实例的 "
1634
+ ":c:member:`~PyVarObject.ob_size` 字段中。 请注意在此之后 "
1635
+ ":c:member:`~PyVarObject.ob_size` 字段可能还有其他用处。 例如,:py:type:`int` "
1636
+ "实例会以具体实现所定义的方式来使用 :c:member:`~PyVarObject.ob_size` 的比特位;下层的存储及其大小应当使用 "
1637
+ ":c:func:`PyLong_Export` 来访问。"
1627
1638
1628
1639
#: ../../c-api/typeobj.rst:619
1629
1640
msgid ""
1630
1641
"The :c:member:`~PyVarObject.ob_size` field should be accessed using the "
1631
1642
":c:func:`Py_SIZE()` and :c:func:`Py_SET_SIZE()` macros."
1632
1643
msgstr ""
1644
+ ":c:member:`~PyVarObject.ob_size` 字段应当使用 :c:func:`Py_SIZE()` 和 "
1645
+ ":c:func:`Py_SET_SIZE()` 宏来访问。"
1633
1646
1634
1647
#: ../../c-api/typeobj.rst:622
1635
1648
msgid ""
@@ -1640,6 +1653,10 @@ msgid ""
1640
1653
":py:type:`int`, avoid reading lists' :c:member:`!ob_size` directly. Call "
1641
1654
":c:func:`PyList_Size` instead.)"
1642
1655
msgstr ""
1656
+ "此外,实例布局中存在 :c:member:`~PyVarObject.ob_size` 字段并不意味着该实例结构体是可变长度的。 "
1657
+ "例如,:py:type:`list` 类型实例即为固定长度,虽然其实例具有 :c:member:`~PyVarObject.ob_size` 字段。 "
1658
+ "(和 :py:type:`int` 一样,请避免直接读取 list 的 :c:member:`!ob_size`。 要改为调用 "
1659
+ ":c:func:`PyList_Size` 函数。)"
1643
1660
1644
1661
#: ../../c-api/typeobj.rst:629
1645
1662
msgid ""
0 commit comments