@@ -1167,21 +1167,24 @@ Mapping Object Structures
1167
1167
1168
1168
.. c :member :: lenfunc PyMappingMethods.mp_length
1169
1169
1170
- This function is used by :c:func: `PyMapping_Length ` and
1170
+ This function is used by :c:func: `PyMapping_Size ` and
1171
1171
:c:func: `PyObject_Size `, and has the same signature. This slot may be set to
1172
1172
*NULL * if the object has no defined length.
1173
1173
1174
1174
.. c :member :: binaryfunc PyMappingMethods.mp_subscript
1175
1175
1176
- This function is used by :c:func: `PyObject_GetItem ` and has the same
1177
- signature. This slot must be filled for the :c:func: `PyMapping_Check `
1178
- function to return ``1 ``, it can be *NULL * otherwise.
1176
+ This function is used by :c:func: `PyObject_GetItem ` and
1177
+ :c:func: `PySequence_GetSlice `, and has the same signature as
1178
+ :c:func: `!PyObject_GetItem `. This slot must be filled for the
1179
+ :c:func: `PyMapping_Check ` function to return ``1 ``, it can be *NULL *
1180
+ otherwise.
1179
1181
1180
1182
.. c :member :: objobjargproc PyMappingMethods.mp_ass_subscript
1181
1183
1182
- This function is used by :c:func: `PyObject_SetItem ` and
1183
- :c:func: `PyObject_DelItem `. It has the same signature as
1184
- :c:func: `PyObject_SetItem `, but *v * can also be set to *NULL * to delete
1184
+ This function is used by :c:func: `PyObject_SetItem `,
1185
+ :c:func: `PyObject_DelItem `, :c:func: `PyObject_SetSlice ` and
1186
+ :c:func: `PyObject_DelSlice `. It has the same signature as
1187
+ :c:func: `!PyObject_SetItem `, but *v * can also be set to *NULL * to delete
1185
1188
an item. If this slot is *NULL *, the object does not support item
1186
1189
assignment and deletion.
1187
1190
@@ -1201,26 +1204,29 @@ Sequence Object Structures
1201
1204
1202
1205
.. c :member :: lenfunc PySequenceMethods.sq_length
1203
1206
1204
- This function is used by :c:func: `PySequence_Size ` and :c:func: `PyObject_Size `,
1205
- and has the same signature.
1207
+ This function is used by :c:func: `PySequence_Size ` and
1208
+ :c:func: `PyObject_Size `, and has the same signature. It is also used for
1209
+ handling negative indices via the :c:member: `~PySequenceMethods.sq_item `
1210
+ and the :c:member: `~PySequenceMethods.sq_ass_item ` slots.
1206
1211
1207
1212
.. c :member :: binaryfunc PySequenceMethods.sq_concat
1208
1213
1209
1214
This function is used by :c:func: `PySequence_Concat ` and has the same
1210
1215
signature. It is also used by the ``+ `` operator, after trying the numeric
1211
- addition via the :c:member: `~PyTypeObject.tp_as_number .nb_add ` slot.
1216
+ addition via the :c:member: `~PyNumberMethods .nb_add ` slot.
1212
1217
1213
1218
.. c :member :: ssizeargfunc PySequenceMethods.sq_repeat
1214
1219
1215
1220
This function is used by :c:func: `PySequence_Repeat ` and has the same
1216
1221
signature. It is also used by the ``* `` operator, after trying numeric
1217
- multiplication via the :c:member: `~PyTypeObject.tp_as_number.nb_multiply `
1218
- slot.
1222
+ multiplication via the :c:member: `~PyNumberMethods.nb_multiply ` slot.
1219
1223
1220
1224
.. c :member :: ssizeargfunc PySequenceMethods.sq_item
1221
1225
1222
1226
This function is used by :c:func: `PySequence_GetItem ` and has the same
1223
- signature. This slot must be filled for the :c:func: `PySequence_Check `
1227
+ signature. It is also used by :c:func: `PyObject_GetItem `, after trying
1228
+ the subscription via the :c:member: `~PyMappingMethods.mp_subscript ` slot.
1229
+ This slot must be filled for the :c:func: `PySequence_Check `
1224
1230
function to return ``1 ``, it can be *NULL * otherwise.
1225
1231
1226
1232
Negative indexes are handled as follows: if the :attr: `sq_length ` slot is
@@ -1231,28 +1237,36 @@ Sequence Object Structures
1231
1237
.. c :member :: ssizeobjargproc PySequenceMethods.sq_ass_item
1232
1238
1233
1239
This function is used by :c:func: `PySequence_SetItem ` and has the same
1234
- signature. This slot may be left to *NULL * if the object does not support
1240
+ signature. It is also used by :c:func: `PyObject_SetItem ` and
1241
+ :c:func: `PyObject_DelItem `, after trying the item assignment and deletion
1242
+ via the :c:member: `~PyMappingMethods.mp_ass_subscript ` slot.
1243
+ This slot may be left to *NULL * if the object does not support
1235
1244
item assignment and deletion.
1236
1245
1237
1246
.. c :member :: objobjproc PySequenceMethods.sq_contains
1238
1247
1239
1248
This function may be used by :c:func: `PySequence_Contains ` and has the same
1240
1249
signature. This slot may be left to *NULL *, in this case
1241
- :c:func: `PySequence_Contains ` simply traverses the sequence until it finds a
1242
- match.
1250
+ :c:func: `! PySequence_Contains ` simply traverses the sequence until it
1251
+ finds a match.
1243
1252
1244
1253
.. c :member :: binaryfunc PySequenceMethods.sq_inplace_concat
1245
1254
1246
1255
This function is used by :c:func: `PySequence_InPlaceConcat ` and has the same
1247
- signature. It should modify its first operand, and return it.
1256
+ signature. It should modify its first operand, and return it. This slot
1257
+ may be left to *NULL *, in this case :c:func: `!PySequence_InPlaceConcat `
1258
+ will fall back to :c:func: `PySequence_Concat `. It is also used by the
1259
+ augmented assignment ``+= ``, after trying numeric inplace addition
1260
+ via the :c:member: `~PyNumberMethods.nb_inplace_add ` slot.
1248
1261
1249
1262
.. c :member :: ssizeargfunc PySequenceMethods.sq_inplace_repeat
1250
1263
1251
1264
This function is used by :c:func: `PySequence_InPlaceRepeat ` and has the same
1252
- signature. It should modify its first operand, and return it.
1253
-
1254
- .. XXX need to explain precedence between mapping and sequence
1255
- .. XXX explains when to implement the sq_inplace_* slots
1265
+ signature. It should modify its first operand, and return it. This slot
1266
+ may be left to *NULL *, in this case :c:func: `!PySequence_InPlaceRepeat `
1267
+ will fall back to :c:func: `PySequence_Repeat `. It is also used by the
1268
+ augmented assignment ``*= ``, after trying numeric inplace multiplication
1269
+ via the :c:member: `~PyNumberMethods.nb_inplace_multiply ` slot.
1256
1270
1257
1271
1258
1272
.. _buffer-structs :
0 commit comments