@@ -485,17 +485,17 @@ PyObject Slots
485
485
--------------
486
486
487
487
The type object structure extends the :c:type: `PyVarObject ` structure. The
488
- :attr: ` ob_size ` field is used for dynamic types (created by :func: `type_new `,
488
+ :c:member: ` ~PyVarObject. ob_size ` field is used for dynamic types (created by :func: `type_new `,
489
489
usually called from a class statement). Note that :c:data: `PyType_Type ` (the
490
490
metatype) initializes :c:member: `~PyTypeObject.tp_itemsize `, which means that its instances (i.e.
491
- type objects) *must * have the :attr: ` ob_size ` field.
491
+ type objects) *must * have the :c:member: ` ~PyVarObject. ob_size ` field.
492
492
493
493
494
494
.. c :member :: Py_ssize_t PyObject.ob_refcnt
495
495
496
496
This is the type object's reference count, initialized to ``1 `` by the
497
497
``PyObject_HEAD_INIT `` macro. Note that for :ref: `statically allocated type
498
- objects <static-types>`, the type's instances (objects whose :attr: ` ob_type `
498
+ objects <static-types>`, the type's instances (objects whose :c:member: ` ~PyObject. ob_type `
499
499
points back to the type) do *not * count as references. But for
500
500
:ref: `dynamically allocated type objects <heap-types >`, the instances *do *
501
501
count as references.
@@ -519,8 +519,8 @@ type objects) *must* have the :attr:`ob_size` field.
519
519
Foo_Type.ob_type = &PyType_Type;
520
520
521
521
This should be done before any instances of the type are created.
522
- :c:func: `PyType_Ready ` checks if :attr: ` ob_type ` is ``NULL ``, and if so,
523
- initializes it to the :attr: ` ob_type ` field of the base class.
522
+ :c:func: `PyType_Ready ` checks if :c:member: ` ~PyObject. ob_type ` is ``NULL ``, and if so,
523
+ initializes it to the :c:member: ` ~PyObject. ob_type ` field of the base class.
524
524
:c:func: `PyType_Ready ` will not change this field if it is non-zero.
525
525
526
526
**Inheritance: **
@@ -619,20 +619,20 @@ and :c:data:`PyType_Type` effectively act as defaults.)
619
619
instances have the same size, given in :c:member: `~PyTypeObject.tp_basicsize `.
620
620
621
621
For a type with variable-length instances, the instances must have an
622
- :attr: ` ob_size ` field, and the instance size is :c:member: `~PyTypeObject.tp_basicsize ` plus N
622
+ :c:member: ` ~PyVarObject. ob_size ` field, and the instance size is :c:member: `~PyTypeObject.tp_basicsize ` plus N
623
623
times :c:member: `~PyTypeObject.tp_itemsize `, where N is the "length" of the object. The value of
624
- N is typically stored in the instance's :attr: ` ob_size ` field. There are
625
- exceptions: for example, ints use a negative :attr: ` ob_size ` to indicate a
624
+ N is typically stored in the instance's :c:member: ` ~PyVarObject. ob_size ` field. There are
625
+ exceptions: for example, ints use a negative :c:member: ` ~PyVarObject. ob_size ` to indicate a
626
626
negative number, and N is ``abs(ob_size) `` there. Also, the presence of an
627
- :attr: ` ob_size ` field in the instance layout doesn't mean that the instance
627
+ :c:member: ` ~PyVarObject. ob_size ` field in the instance layout doesn't mean that the instance
628
628
structure is variable-length (for example, the structure for the list type has
629
- fixed-length instances, yet those instances have a meaningful :attr: ` ob_size `
629
+ fixed-length instances, yet those instances have a meaningful :c:member: ` ~PyVarObject. ob_size `
630
630
field).
631
631
632
632
The basic size includes the fields in the instance declared by the macro
633
633
:c:macro: `PyObject_HEAD ` or :c:macro: `PyObject_VAR_HEAD ` (whichever is used to
634
- declare the instance struct) and this in turn includes the :attr: ` _ob_prev ` and
635
- :attr: ` _ob_next ` fields if they are present. This means that the only correct
634
+ declare the instance struct) and this in turn includes the :c:member: ` ~PyObject. _ob_prev ` and
635
+ :c:member: ` ~PyObject. _ob_next ` fields if they are present. This means that the only correct
636
636
way to get an initializer for the :c:member: `~PyTypeObject.tp_basicsize ` is to use the
637
637
``sizeof `` operator on the struct used to declare the instance layout.
638
638
The basic size does not include the GC header size.
@@ -764,7 +764,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
764
764
765
765
**Inheritance: **
766
766
767
- Group: :attr: ` tp_getattr `, :attr: ` tp_getattro `
767
+ Group: :c:member: ` ~PyTypeObject. tp_getattr `, :c:member: ` ~PyTypeObject. tp_getattro `
768
768
769
769
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_getattro `: a subtype
770
770
inherits both :c:member: `~PyTypeObject.tp_getattr ` and :c:member: `~PyTypeObject.tp_getattro ` from its base type when
@@ -781,7 +781,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
781
781
782
782
**Inheritance: **
783
783
784
- Group: :attr: ` tp_setattr `, :attr: ` tp_setattro `
784
+ Group: :c:member: ` ~PyTypeObject. tp_setattr `, :c:member: ` ~PyTypeObject. tp_setattro `
785
785
786
786
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_setattro `: a subtype
787
787
inherits both :c:member: `~PyTypeObject.tp_setattr ` and :c:member: `~PyTypeObject.tp_setattro ` from its base type when
@@ -883,7 +883,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
883
883
normal return value; when an error occurs during the computation of the hash
884
884
value, the function should set an exception and return ``-1 ``.
885
885
886
- When this field is not set (*and * :attr: ` tp_richcompare ` is not set),
886
+ When this field is not set (*and * :c:member: ` ~PyTypeObject. tp_richcompare ` is not set),
887
887
an attempt to take the hash of the object raises :exc: `TypeError `.
888
888
This is the same as setting it to :c:func: `PyObject_HashNotImplemented `.
889
889
@@ -897,7 +897,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
897
897
898
898
**Inheritance: **
899
899
900
- Group: :attr: ` tp_hash `, :attr: ` tp_richcompare `
900
+ Group: :c:member: ` ~PyTypeObject. tp_hash `, :c:member: ` ~PyTypeObject. tp_richcompare `
901
901
902
902
This field is inherited by subtypes together with
903
903
:c:member: `~PyTypeObject.tp_richcompare `: a subtype inherits both of
@@ -956,7 +956,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
956
956
957
957
**Inheritance: **
958
958
959
- Group: :attr: ` tp_getattr `, :attr: ` tp_getattro `
959
+ Group: :c:member: ` ~PyTypeObject. tp_getattr `, :c:member: ` ~PyTypeObject. tp_getattro `
960
960
961
961
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_getattr `: a subtype
962
962
inherits both :c:member: `~PyTypeObject.tp_getattr ` and :c:member: `~PyTypeObject.tp_getattro ` from its base type when
@@ -982,7 +982,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
982
982
983
983
**Inheritance: **
984
984
985
- Group: :attr: ` tp_setattr `, :attr: ` tp_setattro `
985
+ Group: :c:member: ` ~PyTypeObject. tp_setattr `, :c:member: ` ~PyTypeObject. tp_setattro `
986
986
987
987
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_setattr `: a subtype
988
988
inherits both :c:member: `~PyTypeObject.tp_setattr ` and :c:member: `~PyTypeObject.tp_setattro ` from its base type when
@@ -1047,7 +1047,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
1047
1047
1048
1048
This bit is set when the type object itself is allocated on the heap, for
1049
1049
example, types created dynamically using :c:func: `PyType_FromSpec `. In this
1050
- case, the :attr: ` ob_type ` field of its instances is considered a reference to
1050
+ case, the :c:member: ` ~PyObject. ob_type ` field of its instances is considered a reference to
1051
1051
the type, and the type object is INCREF'ed when a new instance is created, and
1052
1052
DECREF'ed when an instance is destroyed (this does not apply to instances of
1053
1053
subtypes; only the type referenced by the instance's ob_type gets INCREF'ed or
@@ -1100,13 +1100,13 @@ and :c:data:`PyType_Type` effectively act as defaults.)
1100
1100
1101
1101
**Inheritance: **
1102
1102
1103
- Group: :c:macro: `Py_TPFLAGS_HAVE_GC `, :attr: ` tp_traverse `, :attr: ` tp_clear `
1103
+ Group: :c:macro: `Py_TPFLAGS_HAVE_GC `, :c:member: ` ~PyTypeObject. tp_traverse `, :c:member: ` ~PyTypeObject. tp_clear `
1104
1104
1105
1105
The :c:macro: `Py_TPFLAGS_HAVE_GC ` flag bit is inherited
1106
- together with the :attr: ` tp_traverse ` and :attr: ` tp_clear `
1106
+ together with the :c:member: ` ~PyTypeObject. tp_traverse ` and :c:member: ` ~PyTypeObject. tp_clear `
1107
1107
fields, i.e. if the :c:macro: `Py_TPFLAGS_HAVE_GC ` flag bit is
1108
- clear in the subtype and the :attr: ` tp_traverse ` and
1109
- :attr: ` tp_clear ` fields in the subtype exist and have ``NULL ``
1108
+ clear in the subtype and the :c:member: ` ~PyTypeObject. tp_traverse ` and
1109
+ :c:member: ` ~PyTypeObject. tp_clear ` fields in the subtype exist and have ``NULL ``
1110
1110
values.
1111
1111
1112
1112
@@ -1421,7 +1421,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
1421
1421
1422
1422
**Inheritance: **
1423
1423
1424
- Group: :c:macro: `Py_TPFLAGS_HAVE_GC `, :attr: ` tp_traverse `, :attr: ` tp_clear `
1424
+ Group: :c:macro: `Py_TPFLAGS_HAVE_GC `, :c:member: ` ~PyTypeObject. tp_traverse `, :c:member: ` ~PyTypeObject. tp_clear `
1425
1425
1426
1426
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_clear ` and the
1427
1427
:c:macro: `Py_TPFLAGS_HAVE_GC ` flag bit: the flag bit, :c:member: `~PyTypeObject.tp_traverse `, and
@@ -1488,7 +1488,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
1488
1488
1489
1489
**Inheritance: **
1490
1490
1491
- Group: :c:macro: `Py_TPFLAGS_HAVE_GC `, :attr: ` tp_traverse `, :attr: ` tp_clear `
1491
+ Group: :c:macro: `Py_TPFLAGS_HAVE_GC `, :c:member: ` ~PyTypeObject. tp_traverse `, :c:member: ` ~PyTypeObject. tp_clear `
1492
1492
1493
1493
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_traverse ` and the
1494
1494
:c:macro: `Py_TPFLAGS_HAVE_GC ` flag bit: the flag bit, :c:member: `~PyTypeObject.tp_traverse `, and
@@ -1547,7 +1547,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
1547
1547
1548
1548
**Inheritance: **
1549
1549
1550
- Group: :attr: ` tp_hash `, :attr: ` tp_richcompare `
1550
+ Group: :c:member: ` ~PyTypeObject. tp_hash `, :c:member: ` ~PyTypeObject. tp_richcompare `
1551
1551
1552
1552
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_hash `:
1553
1553
a subtype inherits :c:member: `~PyTypeObject.tp_richcompare ` and :c:member: `~PyTypeObject.tp_hash ` when
@@ -1556,9 +1556,9 @@ and :c:data:`PyType_Type` effectively act as defaults.)
1556
1556
1557
1557
**Default: **
1558
1558
1559
- :c:data: `PyBaseObject_Type ` provides a :attr: ` tp_richcompare `
1559
+ :c:data: `PyBaseObject_Type ` provides a :c:member: ` ~PyTypeObject. tp_richcompare `
1560
1560
implementation, which may be inherited. However, if only
1561
- :attr: ` tp_hash ` is defined, not even the inherited function is used
1561
+ :c:member: ` ~PyTypeObject. tp_hash ` is defined, not even the inherited function is used
1562
1562
and instances of the type will not be able to participate in any
1563
1563
comparisons.
1564
1564
@@ -2374,9 +2374,9 @@ Sequence Object Structures
2374
2374
This slot must be filled for the :c:func: `PySequence_Check `
2375
2375
function to return ``1 ``, it can be ``NULL `` otherwise.
2376
2376
2377
- Negative indexes are handled as follows: if the :attr: ` sq_length ` slot is
2377
+ Negative indexes are handled as follows: if the :c:member: ` ~PySequenceMethods. sq_length ` slot is
2378
2378
filled, it is called and the sequence length is used to compute a positive
2379
- index which is passed to :attr: ` sq_item `. If :attr: ` sq_length ` is ``NULL ``,
2379
+ index which is passed to :c:member: ` ~PySequenceMethods. sq_item `. If :c:member: ` ! sq_length ` is ``NULL ``,
2380
2380
the index is passed as is to the function.
2381
2381
2382
2382
.. c :member :: ssizeobjargproc PySequenceMethods.sq_ass_item
@@ -2586,8 +2586,8 @@ Slot Type typedefs
2586
2586
The purpose of this function is to separate memory allocation from memory
2587
2587
initialization. It should return a pointer to a block of memory of adequate
2588
2588
length for the instance, suitably aligned, and initialized to zeros, but with
2589
- :attr: ` ob_refcnt ` set to ``1 `` and :attr: ` ob_type ` set to the type argument. If
2590
- the type's :c:member: `~PyTypeObject.tp_itemsize ` is non-zero, the object's :attr: ` ob_size ` field
2589
+ :c:member: ` ~PyObject. ob_refcnt ` set to ``1 `` and :c:member: ` ~PyObject. ob_type ` set to the type argument. If
2590
+ the type's :c:member: `~PyTypeObject.tp_itemsize ` is non-zero, the object's :c:member: ` ~PyVarObject. ob_size ` field
2591
2591
should be initialized to *nitems * and the length of the allocated memory block
2592
2592
should be ``tp_basicsize + nitems*tp_itemsize ``, rounded up to a multiple of
2593
2593
``sizeof(void*) ``; otherwise, *nitems * is not used and the length of the block
0 commit comments