@@ -11,7 +11,7 @@ msgid ""
11
11
msgstr ""
12
12
"Project-Id-Version : Python 3.12\n "
13
13
"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 "
15
15
"PO-Revision-Date : 2024-05-11 00:32+0000\n "
16
16
"
Last-Translator :
Rafael Fontenelle <[email protected] >, 2025\n "
17
17
"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -1192,6 +1192,8 @@ msgid ""
1192
1192
":file:`Include/cpython/object.h`. For convenience of reference, this "
1193
1193
"repeats the definition found there:"
1194
1194
msgstr ""
1195
+ "针对 :c:type:`PyTypeObject` 的结构定义可以在 :file:`Include/cpython/object.h` 中找到。 "
1196
+ "为了方便参考,这里复述了其中的定义:"
1195
1197
1196
1198
#: ../../c-api/typeobj.rst:481
1197
1199
msgid ""
@@ -1532,7 +1534,7 @@ msgstr ""
1532
1534
msgid ""
1533
1535
"This field should be accessed using the :c:func:`Py_SIZE()` and "
1534
1536
":c:func:`Py_SET_SIZE()` macros."
1535
- msgstr ""
1537
+ msgstr "该字段应当使用 :c:func:`Py_SIZE()` 和 :c:func:`Py_SET_SIZE()` 宏来访问。 "
1536
1538
1537
1539
#: ../../c-api/typeobj.rst:571
1538
1540
msgid "PyTypeObject Slots"
@@ -1623,6 +1625,10 @@ msgid ""
1623
1625
":c:member:`!tp_basicsize`. (Exceptions to this rule can be made using "
1624
1626
":c:func:`PyUnstable_Object_GC_NewWithExtraData`.)"
1625
1627
msgstr ""
1628
+ "类型可分为两种:实例为固定长度且 :c:member:`!tp_itemsize` 字段值为零的类型;实例为可变长度且 "
1629
+ ":c:member:`!tp_itemsize` 字段值不为零的类型。 对于实例为固定长度的类型,所有实例都具有相同的由 "
1630
+ ":c:member:`!tp_basicsize` 给出的大小。 (这条规则的例外情况可通过使用 "
1631
+ ":c:func:`PyUnstable_Object_GC_NewWithExtraData` 来实现。)"
1626
1632
1627
1633
#: ../../c-api/typeobj.rst:626
1628
1634
msgid ""
@@ -1631,6 +1637,8 @@ msgid ""
1631
1637
":c:member:`!tp_basicsize` plus N times :c:member:`!tp_itemsize`, where N is "
1632
1638
"the \" length\" of the object."
1633
1639
msgstr ""
1640
+ "对于实例为可变长度的类型,其实例必须具有 :c:member:`~PyVarObject.ob_size` 字段,且实例大小为 "
1641
+ ":c:member:`!tp_basicsize` 加 N 乘以 :c:member:`!tp_itemsize`,其中 N 为对象的“长度”。"
1634
1642
1635
1643
#: ../../c-api/typeobj.rst:631
1636
1644
msgid ""
@@ -1642,12 +1650,19 @@ msgid ""
1642
1650
"underlying storage and its size should be acessed using "
1643
1651
":c:func:`PyLong_Export`."
1644
1652
msgstr ""
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` 来访问。"
1645
1658
1646
1659
#: ../../c-api/typeobj.rst:641
1647
1660
msgid ""
1648
1661
"The :c:member:`~PyVarObject.ob_size` field should be accessed using the "
1649
1662
":c:func:`Py_SIZE()` and :c:func:`Py_SET_SIZE()` macros."
1650
1663
msgstr ""
1664
+ ":c:member:`~PyVarObject.ob_size` 字段应当使用 :c:func:`Py_SIZE()` 和 "
1665
+ ":c:func:`Py_SET_SIZE()` 宏来访问。"
1651
1666
1652
1667
#: ../../c-api/typeobj.rst:644
1653
1668
msgid ""
@@ -1658,13 +1673,19 @@ msgid ""
1658
1673
":py:type:`int`, avoid reading lists' :c:member:`!ob_size` directly. Call "
1659
1674
":c:func:`PyList_Size` instead.)"
1660
1675
msgstr ""
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` 函数。)"
1661
1680
1662
1681
#: ../../c-api/typeobj.rst:651
1663
1682
msgid ""
1664
1683
"The :c:member:`!tp_basicsize` includes size needed for data of the type's "
1665
1684
":c:member:`~PyTypeObject.tp_base`, plus any extra data needed by each "
1666
1685
"instance."
1667
1686
msgstr ""
1687
+ ":c:member:`!tp_basicsize` 包括类型的 :c:member:`~PyTypeObject.tp_base` "
1688
+ "所需数据大小,加上每个实例所需额外数据的大小。"
1668
1689
1669
1690
#: ../../c-api/typeobj.rst:655
1670
1691
msgid ""
@@ -1674,6 +1695,9 @@ msgid ""
1674
1695
":c:member:`!tp_basicsize` must be greater than or equal to the base's "
1675
1696
":c:member:`!tp_basicsize`."
1676
1697
msgstr ""
1698
+ "设置 :c:member:`!tp_basicsize` 的正确方式是在被用于声明实例布局的结构体上使用 ``sizeof`` 运算符。 "
1699
+ "这个结构体必须包括被用于声明基类型的结构体。 换句话说,:c:member:`!tp_basicsize` 必须大于等于基类型的 "
1700
+ ":c:member:`!tp_basicsize`。"
1677
1701
1678
1702
#: ../../c-api/typeobj.rst:661
1679
1703
msgid ""
@@ -1683,22 +1707,27 @@ msgid ""
1683
1707
"defined by the macro :c:macro:`PyObject_HEAD` or "
1684
1708
":c:macro:`PyObject_VAR_HEAD`, respectively."
1685
1709
msgstr ""
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` 宏来定义的。"
1686
1713
1687
1714
#: ../../c-api/typeobj.rst:667
1688
1715
msgid ""
1689
1716
"The basic size does not include the GC header size, as that header is not "
1690
1717
"part of :c:macro:`PyObject_HEAD`."
1691
- msgstr ""
1718
+ msgstr "基础大小不包括 GC 标头大小,因为该标头不是 :c:macro:`PyObject_HEAD` 的一部分。 "
1692
1719
1693
1720
#: ../../c-api/typeobj.rst:670
1694
1721
msgid ""
1695
1722
"For cases where struct used to declare the base type is unknown, see "
1696
1723
":c:member:`PyType_Spec.basicsize` and :c:func:`PyType_FromMetaclass`."
1697
1724
msgstr ""
1725
+ "对于用于声明基类型的结构体位置未知的情况,请参见 :c:member:`PyType_Spec.basicsize` 和 "
1726
+ ":c:func:`PyType_FromMetaclass`。"
1698
1727
1699
1728
#: ../../c-api/typeobj.rst:673
1700
1729
msgid "Notes about alignment:"
1701
- msgstr ""
1730
+ msgstr "有关对齐的说明: "
1702
1731
1703
1732
#: ../../c-api/typeobj.rst:675
1704
1733
msgid ""
@@ -1708,6 +1737,9 @@ msgid ""
1708
1737
"when using compiler extensions like ``__attribute__((packed))``, it is up to"
1709
1738
" you."
1710
1739
msgstr ""
1740
+ ":c:member:`!tp_basicsize` 必须是 ``_Alignof(PyObject)`` 的位数。 当如建议的那样在包括了 "
1741
+ ":c:macro:`PyObject_HEAD` 的 ``struct`` 上使用 ``sizeof`` 时,编译器会确保这一点。 当没有使用 C "
1742
+ "``struct``,或者当使用像 ``__attribute__((packed))`` 这样的编译器扩展时,这将是你的责任。"
1711
1743
1712
1744
#: ../../c-api/typeobj.rst:680
1713
1745
msgid ""
@@ -1717,13 +1749,18 @@ msgid ""
1717
1749
"``double``, it is your responsibility that both fields are a multiple of "
1718
1750
"``_Alignof(double)``."
1719
1751
msgstr ""
1752
+ "如果可变条目需要特定的对齐,则 :c:member:`!tp_basicsize` 和 :c:member:`!tp_itemsize` "
1753
+ "必须均为该对齐值的倍数。 举例来说,如果一个类型的可变部分存储了一个 ``double``,你就要负责让这两个字段都是 "
1754
+ "``_Alignof(double)`` 的倍数。"
1720
1755
1721
1756
#: ../../c-api/typeobj.rst:689
1722
1757
msgid ""
1723
1758
"These fields are inherited separately by subtypes. (That is, if the field is"
1724
1759
" set to zero, :c:func:`PyType_Ready` will copy the value from the base type,"
1725
1760
" indicating that the instances do not need additional storage.)"
1726
1761
msgstr ""
1762
+ "这些字段是由子类型分别来继承的。 (也就是说,如果字段被设为零,则 :c:func:`PyType_Ready` "
1763
+ "将拷贝来自基类型的值,这表示实例不需要额外的存储。)"
1727
1764
1728
1765
#: ../../c-api/typeobj.rst:694
1729
1766
msgid ""
@@ -1732,6 +1769,8 @@ msgid ""
1732
1769
"different non-zero value in a subtype (though this depends on the "
1733
1770
"implementation of the base type)."
1734
1771
msgstr ""
1772
+ "如果基类型有一个非零的 :c:member:`~PyTypeObject.tp_itemsize`,那么在子类型中将 "
1773
+ ":c:member:`~PyTypeObject.tp_itemsize` 设置为不同的非零值通常是不安全的(不过这取决于该基类型的具体实现)。"
1735
1774
1736
1775
#: ../../c-api/typeobj.rst:701
1737
1776
msgid ""
0 commit comments