@@ -13,6 +13,11 @@ found in the dictionary of type objects.
1313 Create a new get-set descriptor for extension type *type * from the
1414 :c:type: `PyGetSetDef ` structure *getset *.
1515
16+ Get-set descriptors expose attributes implemented by C getter and setter
17+ functions rather than stored directly in the instance. This is the same kind
18+ of descriptor created for entries in :c:member: `~PyTypeObject.tp_getset `, and
19+ it appears in Python as a :class: `types.GetSetDescriptorType ` object.
20+
1621 On success, return a :term: `strong reference ` to the descriptor. Return
1722 ``NULL `` with an exception set on failure.
1823
@@ -21,6 +26,11 @@ found in the dictionary of type objects.
2126 Create a new member descriptor for extension type *type * from the
2227 :c:type: `PyMemberDef ` structure *member *.
2328
29+ Member descriptors expose fields in the type's C struct as Python
30+ attributes. This is the same kind of descriptor created for entries in
31+ :c:member: `~PyTypeObject.tp_members `, and it appears in Python as a
32+ :class: `types.MemberDescriptorType ` object.
33+
2434 On success, return a :term: `strong reference ` to the descriptor. Return
2535 ``NULL `` with an exception set on failure.
2636
@@ -47,6 +57,11 @@ found in the dictionary of type objects.
4757 Create a new method descriptor for extension type *type * from the
4858 :c:type: `PyMethodDef ` structure *meth *.
4959
60+ Method descriptors expose C functions as methods on a type. This is the same
61+ kind of descriptor created for entries in
62+ :c:member: `~PyTypeObject.tp_methods `, and it appears in Python as a
63+ :class: `types.MethodDescriptorType ` object.
64+
5065 On success, return a :term: `strong reference ` to the descriptor. Return
5166 ``NULL `` with an exception set on failure.
5267
@@ -58,14 +73,25 @@ found in the dictionary of type objects.
5873 objects in Python.
5974
6075
76+ .. c :struct :: wrapperbase
77+
78+ Describes a slot wrapper used by :c:func: `PyDescr_NewWrapper `.
79+
80+ Each ``wrapperbase `` record stores the Python-visible name and metadata for a
81+ special method implemented by a type slot, together with the wrapper
82+ function used to adapt that slot to Python's calling convention.
83+
6184.. c :function :: PyObject* PyDescr_NewWrapper (PyTypeObject *type, struct wrapperbase *base, void *wrapped)
6285
6386 Create a new wrapper descriptor for extension type *type * from the
64- ``struct wrapperbase `` structure *base * and the wrapped C function pointer
87+ :c:struct: `wrapperbase ` structure *base * and the wrapped slot function
88+ pointer
6589 *wrapped *.
6690
67- Wrapper descriptors are used internally to expose special methods
68- implemented by slot wrappers.
91+ Wrapper descriptors expose special methods implemented by type slots. This
92+ is the same kind of descriptor that CPython creates for slot-based special
93+ methods such as ``__repr__ `` or ``__add__ ``, and it appears in Python as a
94+ :class: `types.WrapperDescriptorType ` object.
6995
7096 On success, return a :term: `strong reference ` to the descriptor. Return
7197 ``NULL `` with an exception set on failure.
@@ -84,6 +110,11 @@ found in the dictionary of type objects.
84110 Create a new class method descriptor for extension type *type * from the
85111 :c:type: `PyMethodDef ` structure *method *.
86112
113+ Class method descriptors expose C methods that receive the class rather than
114+ an instance when accessed. This is the same kind of descriptor created for
115+ ``METH_CLASS `` entries in :c:member: `~PyTypeObject.tp_methods `, and it
116+ appears in Python as a :class: `types.ClassMethodDescriptorType ` object.
117+
87118 On success, return a :term: `strong reference ` to the descriptor. Return
88119 ``NULL `` with an exception set on failure.
89120
@@ -97,8 +128,12 @@ found in the dictionary of type objects.
97128.. c :function :: PyObject* PyWrapper_New (PyObject *d, PyObject *self)
98129
99130 Create a new bound wrapper object from the wrapper descriptor *d * and the
100- object *self *. The returned object appears in Python as a
101- :class: `types.MethodWrapperType ` instance.
131+ instance *self *.
132+
133+ This is the bound form of a wrapper descriptor created by
134+ :c:func: `PyDescr_NewWrapper `. CPython creates these objects when a slot
135+ wrapper is accessed through an instance, and they appear in Python as
136+ :class: `types.MethodWrapperType ` objects.
102137
103138 On success, return a :term: `strong reference ` to the wrapper object. Return
104139 ``NULL `` with an exception set on failure.
0 commit comments