@@ -483,17 +483,17 @@ PyObject Slots
483
483
--------------
484
484
485
485
The type object structure extends the :c:type: `PyVarObject ` structure. The
486
- :attr: ` ob_size ` field is used for dynamic types (created by :func: `type_new `,
486
+ :c:member: ` ~PyVarObject. ob_size ` field is used for dynamic types (created by :func: `type_new `,
487
487
usually called from a class statement). Note that :c:data: `PyType_Type ` (the
488
488
metatype) initializes :c:member: `~PyTypeObject.tp_itemsize `, which means that its instances (i.e.
489
- type objects) *must * have the :attr: ` ob_size ` field.
489
+ type objects) *must * have the :c:member: ` ~PyVarObject. ob_size ` field.
490
490
491
491
492
492
.. c :member :: Py_ssize_t PyObject.ob_refcnt
493
493
494
494
This is the type object's reference count, initialized to ``1 `` by the
495
495
``PyObject_HEAD_INIT `` macro. Note that for :ref: `statically allocated type
496
- objects <static-types>`, the type's instances (objects whose :attr: ` ob_type `
496
+ objects <static-types>`, the type's instances (objects whose :c:member: ` ~PyObject. ob_type `
497
497
points back to the type) do *not * count as references. But for
498
498
:ref: `dynamically allocated type objects <heap-types >`, the instances *do *
499
499
count as references.
@@ -517,8 +517,8 @@ type objects) *must* have the :attr:`ob_size` field.
517
517
Foo_Type.ob_type = &PyType_Type;
518
518
519
519
This should be done before any instances of the type are created.
520
- :c:func: `PyType_Ready ` checks if :attr: ` ob_type ` is ``NULL ``, and if so,
521
- initializes it to the :attr: ` ob_type ` field of the base class.
520
+ :c:func: `PyType_Ready ` checks if :c:member: ` ~PyObject. ob_type ` is ``NULL ``, and if so,
521
+ initializes it to the :c:member: ` ~PyObject. ob_type ` field of the base class.
522
522
:c:func: `PyType_Ready ` will not change this field if it is non-zero.
523
523
524
524
**Inheritance: **
@@ -617,20 +617,20 @@ and :c:data:`PyType_Type` effectively act as defaults.)
617
617
instances have the same size, given in :c:member: `~PyTypeObject.tp_basicsize `.
618
618
619
619
For a type with variable-length instances, the instances must have an
620
- :attr: ` ob_size ` field, and the instance size is :c:member: `~PyTypeObject.tp_basicsize ` plus N
620
+ :c:member: ` ~PyVarObject. ob_size ` field, and the instance size is :c:member: `~PyTypeObject.tp_basicsize ` plus N
621
621
times :c:member: `~PyTypeObject.tp_itemsize `, where N is the "length" of the object. The value of
622
- N is typically stored in the instance's :attr: ` ob_size ` field. There are
623
- exceptions: for example, ints use a negative :attr: ` ob_size ` to indicate a
622
+ N is typically stored in the instance's :c:member: ` ~PyVarObject. ob_size ` field. There are
623
+ exceptions: for example, ints use a negative :c:member: ` ~PyVarObject. ob_size ` to indicate a
624
624
negative number, and N is ``abs(ob_size) `` there. Also, the presence of an
625
- :attr: ` ob_size ` field in the instance layout doesn't mean that the instance
625
+ :c:member: ` ~PyVarObject. ob_size ` field in the instance layout doesn't mean that the instance
626
626
structure is variable-length (for example, the structure for the list type has
627
- fixed-length instances, yet those instances have a meaningful :attr: ` ob_size `
627
+ fixed-length instances, yet those instances have a meaningful :c:member: ` ~PyVarObject. ob_size `
628
628
field).
629
629
630
630
The basic size includes the fields in the instance declared by the macro
631
631
:c:macro: `PyObject_HEAD ` or :c:macro: `PyObject_VAR_HEAD ` (whichever is used to
632
- declare the instance struct) and this in turn includes the :attr: ` _ob_prev ` and
633
- :attr: ` _ob_next ` fields if they are present. This means that the only correct
632
+ declare the instance struct) and this in turn includes the :c:member: ` ~PyObject. _ob_prev ` and
633
+ :c:member: ` ~PyObject. _ob_next ` fields if they are present. This means that the only correct
634
634
way to get an initializer for the :c:member: `~PyTypeObject.tp_basicsize ` is to use the
635
635
``sizeof `` operator on the struct used to declare the instance layout.
636
636
The basic size does not include the GC header size.
@@ -762,7 +762,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
762
762
763
763
**Inheritance: **
764
764
765
- Group: :attr: ` tp_getattr `, :attr: ` tp_getattro `
765
+ Group: :c:member: ` ~PyTypeObject. tp_getattr `, :c:member: ` ~PyTypeObject. tp_getattro `
766
766
767
767
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_getattro `: a subtype
768
768
inherits both :c:member: `~PyTypeObject.tp_getattr ` and :c:member: `~PyTypeObject.tp_getattro ` from its base type when
@@ -779,7 +779,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
779
779
780
780
**Inheritance: **
781
781
782
- Group: :attr: ` tp_setattr `, :attr: ` tp_setattro `
782
+ Group: :c:member: ` ~PyTypeObject. tp_setattr `, :c:member: ` ~PyTypeObject. tp_setattro `
783
783
784
784
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_setattro `: a subtype
785
785
inherits both :c:member: `~PyTypeObject.tp_setattr ` and :c:member: `~PyTypeObject.tp_setattro ` from its base type when
@@ -881,7 +881,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
881
881
normal return value; when an error occurs during the computation of the hash
882
882
value, the function should set an exception and return ``-1 ``.
883
883
884
- When this field is not set (*and * :attr: ` tp_richcompare ` is not set),
884
+ When this field is not set (*and * :c:member: ` ~PyTypeObject. tp_richcompare ` is not set),
885
885
an attempt to take the hash of the object raises :exc: `TypeError `.
886
886
This is the same as setting it to :c:func: `PyObject_HashNotImplemented `.
887
887
@@ -895,7 +895,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
895
895
896
896
**Inheritance: **
897
897
898
- Group: :attr: ` tp_hash `, :attr: ` tp_richcompare `
898
+ Group: :c:member: ` ~PyTypeObject. tp_hash `, :c:member: ` ~PyTypeObject. tp_richcompare `
899
899
900
900
This field is inherited by subtypes together with
901
901
:c:member: `~PyTypeObject.tp_richcompare `: a subtype inherits both of
@@ -954,7 +954,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
954
954
955
955
**Inheritance: **
956
956
957
- Group: :attr: ` tp_getattr `, :attr: ` tp_getattro `
957
+ Group: :c:member: ` ~PyTypeObject. tp_getattr `, :c:member: ` ~PyTypeObject. tp_getattro `
958
958
959
959
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_getattr `: a subtype
960
960
inherits both :c:member: `~PyTypeObject.tp_getattr ` and :c:member: `~PyTypeObject.tp_getattro ` from its base type when
@@ -980,7 +980,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
980
980
981
981
**Inheritance: **
982
982
983
- Group: :attr: ` tp_setattr `, :attr: ` tp_setattro `
983
+ Group: :c:member: ` ~PyTypeObject. tp_setattr `, :c:member: ` ~PyTypeObject. tp_setattro `
984
984
985
985
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_setattr `: a subtype
986
986
inherits both :c:member: `~PyTypeObject.tp_setattr ` and :c:member: `~PyTypeObject.tp_setattro ` from its base type when
@@ -1046,7 +1046,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
1046
1046
1047
1047
This bit is set when the type object itself is allocated on the heap, for
1048
1048
example, types created dynamically using :c:func: `PyType_FromSpec `. In this
1049
- case, the :attr: ` ob_type ` field of its instances is considered a reference to
1049
+ case, the :c:member: ` ~PyObject. ob_type ` field of its instances is considered a reference to
1050
1050
the type, and the type object is INCREF'ed when a new instance is created, and
1051
1051
DECREF'ed when an instance is destroyed (this does not apply to instances of
1052
1052
subtypes; only the type referenced by the instance's ob_type gets INCREF'ed or
@@ -1099,13 +1099,13 @@ and :c:data:`PyType_Type` effectively act as defaults.)
1099
1099
1100
1100
**Inheritance: **
1101
1101
1102
- Group: :c:macro: `Py_TPFLAGS_HAVE_GC `, :attr: ` tp_traverse `, :attr: ` tp_clear `
1102
+ Group: :c:macro: `Py_TPFLAGS_HAVE_GC `, :c:member: ` ~PyTypeObject. tp_traverse `, :c:member: ` ~PyTypeObject. tp_clear `
1103
1103
1104
1104
The :c:macro: `Py_TPFLAGS_HAVE_GC ` flag bit is inherited
1105
- together with the :attr: ` tp_traverse ` and :attr: ` tp_clear `
1105
+ together with the :c:member: ` ~PyTypeObject. tp_traverse ` and :c:member: ` ~PyTypeObject. tp_clear `
1106
1106
fields, i.e. if the :c:macro: `Py_TPFLAGS_HAVE_GC ` flag bit is
1107
- clear in the subtype and the :attr: ` tp_traverse ` and
1108
- :attr: ` tp_clear ` fields in the subtype exist and have ``NULL ``
1107
+ clear in the subtype and the :c:member: ` ~PyTypeObject. tp_traverse ` and
1108
+ :c:member: ` ~PyTypeObject. tp_clear ` fields in the subtype exist and have ``NULL ``
1109
1109
values.
1110
1110
1111
1111
@@ -1357,7 +1357,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
1357
1357
1358
1358
**Inheritance: **
1359
1359
1360
- Group: :c:macro: `Py_TPFLAGS_HAVE_GC `, :attr: ` tp_traverse `, :attr: ` tp_clear `
1360
+ Group: :c:macro: `Py_TPFLAGS_HAVE_GC `, :c:member: ` ~PyTypeObject. tp_traverse `, :c:member: ` ~PyTypeObject. tp_clear `
1361
1361
1362
1362
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_clear ` and the
1363
1363
:c:macro: `Py_TPFLAGS_HAVE_GC ` flag bit: the flag bit, :c:member: `~PyTypeObject.tp_traverse `, and
@@ -1424,7 +1424,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
1424
1424
1425
1425
**Inheritance: **
1426
1426
1427
- Group: :c:macro: `Py_TPFLAGS_HAVE_GC `, :attr: ` tp_traverse `, :attr: ` tp_clear `
1427
+ Group: :c:macro: `Py_TPFLAGS_HAVE_GC `, :c:member: ` ~PyTypeObject. tp_traverse `, :c:member: ` ~PyTypeObject. tp_clear `
1428
1428
1429
1429
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_traverse ` and the
1430
1430
:c:macro: `Py_TPFLAGS_HAVE_GC ` flag bit: the flag bit, :c:member: `~PyTypeObject.tp_traverse `, and
@@ -1483,7 +1483,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
1483
1483
1484
1484
**Inheritance: **
1485
1485
1486
- Group: :attr: ` tp_hash `, :attr: ` tp_richcompare `
1486
+ Group: :c:member: ` ~PyTypeObject. tp_hash `, :c:member: ` ~PyTypeObject. tp_richcompare `
1487
1487
1488
1488
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_hash `:
1489
1489
a subtype inherits :c:member: `~PyTypeObject.tp_richcompare ` and :c:member: `~PyTypeObject.tp_hash ` when
@@ -1492,9 +1492,9 @@ and :c:data:`PyType_Type` effectively act as defaults.)
1492
1492
1493
1493
**Default: **
1494
1494
1495
- :c:data: `PyBaseObject_Type ` provides a :attr: ` tp_richcompare `
1495
+ :c:data: `PyBaseObject_Type ` provides a :c:member: ` ~PyTypeObject. tp_richcompare `
1496
1496
implementation, which may be inherited. However, if only
1497
- :attr: ` tp_hash ` is defined, not even the inherited function is used
1497
+ :c:member: ` ~PyTypeObject. tp_hash ` is defined, not even the inherited function is used
1498
1498
and instances of the type will not be able to participate in any
1499
1499
comparisons.
1500
1500
@@ -2288,9 +2288,9 @@ Sequence Object Structures
2288
2288
This slot must be filled for the :c:func: `PySequence_Check `
2289
2289
function to return ``1 ``, it can be ``NULL `` otherwise.
2290
2290
2291
- Negative indexes are handled as follows: if the :attr: ` sq_length ` slot is
2291
+ Negative indexes are handled as follows: if the :c:member: ` ~PySequenceMethods. sq_length ` slot is
2292
2292
filled, it is called and the sequence length is used to compute a positive
2293
- index which is passed to :attr: ` sq_item `. If :attr: ` sq_length ` is ``NULL ``,
2293
+ index which is passed to :c:member: ` ~PySequenceMethods. sq_item `. If :c:member: ` ! sq_length ` is ``NULL ``,
2294
2294
the index is passed as is to the function.
2295
2295
2296
2296
.. c :member :: ssizeobjargproc PySequenceMethods.sq_ass_item
@@ -2500,8 +2500,8 @@ Slot Type typedefs
2500
2500
The purpose of this function is to separate memory allocation from memory
2501
2501
initialization. It should return a pointer to a block of memory of adequate
2502
2502
length for the instance, suitably aligned, and initialized to zeros, but with
2503
- :attr: ` ob_refcnt ` set to ``1 `` and :attr: ` ob_type ` set to the type argument. If
2504
- the type's :c:member: `~PyTypeObject.tp_itemsize ` is non-zero, the object's :attr: ` ob_size ` field
2503
+ :c:member: ` ~PyObject. ob_refcnt ` set to ``1 `` and :c:member: ` ~PyObject. ob_type ` set to the type argument. If
2504
+ the type's :c:member: `~PyTypeObject.tp_itemsize ` is non-zero, the object's :c:member: ` ~PyVarObject. ob_size ` field
2505
2505
should be initialized to *nitems * and the length of the allocated memory block
2506
2506
should be ``tp_basicsize + nitems*tp_itemsize ``, rounded up to a multiple of
2507
2507
``sizeof(void*) ``; otherwise, *nitems * is not used and the length of the block
0 commit comments