Skip to content

Latest commit

 

History

History
899 lines (586 loc) · 31.9 KB

File metadata and controls

899 lines (586 loc) · 31.9 KB
 
Dec 19, 2016
Dec 19, 2016
1
/* Abstract Object Interface (many thanks to Jim Fulton) */
2
Jul 18, 1995
Jul 18, 1995
3
#ifndef Py_ABSTRACTOBJECT_H
4
#define Py_ABSTRACTOBJECT_H
5
#ifdef __cplusplus
6
extern "C" {
7
#endif
8
Dec 6, 2016
Dec 6, 2016
9
/* === Object Protocol ================================================== */
Jul 18, 1995
Jul 18, 1995
10
Dec 6, 2016
Dec 6, 2016
11
/* Implemented elsewhere:
Jul 18, 1995
Jul 18, 1995
12
Dec 15, 2016
Dec 15, 2016
13
int PyObject_Print(PyObject *o, FILE *fp, int flags);
Jul 18, 1995
Jul 18, 1995
14
Dec 15, 2016
Dec 15, 2016
15
Print an object 'o' on file 'fp'. Returns -1 on error. The flags argument
16
is used to enable certain printing options. The only option currently
May 29, 2022
May 29, 2022
17
supported is Py_PRINT_RAW. By default (flags=0), PyObject_Print() formats
18
the object by calling PyObject_Repr(). If flags equals to Py_PRINT_RAW, it
19
formats the object by calling PyObject_Str(). */
Jul 18, 1995
Jul 18, 1995
20
21
Dec 6, 2016
Dec 6, 2016
22
/* Implemented elsewhere:
Jul 18, 1995
Jul 18, 1995
23
Dec 15, 2016
Dec 15, 2016
24
int PyObject_HasAttrString(PyObject *o, const char *attr_name);
25
26
Returns 1 if object 'o' has the attribute attr_name, and 0 otherwise.
Jul 18, 1995
Jul 18, 1995
27
Dec 15, 2016
Dec 15, 2016
28
This is equivalent to the Python expression: hasattr(o,attr_name).
Jul 18, 1995
Jul 18, 1995
29
Dec 15, 2016
Dec 15, 2016
30
This function always succeeds. */
Jul 18, 1995
Jul 18, 1995
31
32
Dec 6, 2016
Dec 6, 2016
33
/* Implemented elsewhere:
Jul 18, 1995
Jul 18, 1995
34
Dec 15, 2016
Dec 15, 2016
35
PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name);
Jul 18, 1995
Jul 18, 1995
36
Dec 15, 2016
Dec 15, 2016
37
Retrieve an attributed named attr_name form object o.
38
Returns the attribute value on success, or NULL on failure.
39
40
This is the equivalent of the Python expression: o.attr_name. */
Jul 18, 1995
Jul 18, 1995
41
42
Dec 6, 2016
Dec 6, 2016
43
/* Implemented elsewhere:
Jul 18, 1995
Jul 18, 1995
44
Dec 15, 2016
Dec 15, 2016
45
int PyObject_HasAttr(PyObject *o, PyObject *attr_name);
Jul 18, 1995
Jul 18, 1995
46
Dec 15, 2016
Dec 15, 2016
47
Returns 1 if o has the attribute attr_name, and 0 otherwise.
Jul 18, 1995
Jul 18, 1995
48
Dec 15, 2016
Dec 15, 2016
49
This is equivalent to the Python expression: hasattr(o,attr_name).
Jul 18, 1995
Jul 18, 1995
50
Dec 15, 2016
Dec 15, 2016
51
This function always succeeds. */
Jul 18, 1995
Jul 18, 1995
52
Dec 6, 2016
Dec 6, 2016
53
/* Implemented elsewhere:
Jul 18, 1995
Jul 18, 1995
54
Dec 15, 2016
Dec 15, 2016
55
PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name);
Jul 18, 1995
Jul 18, 1995
56
Dec 15, 2016
Dec 15, 2016
57
Retrieve an attributed named 'attr_name' form object 'o'.
58
Returns the attribute value on success, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
59
Dec 15, 2016
Dec 15, 2016
60
This is the equivalent of the Python expression: o.attr_name. */
Jul 18, 1995
Jul 18, 1995
61
62
Dec 6, 2016
Dec 6, 2016
63
/* Implemented elsewhere:
Jul 18, 1995
Jul 18, 1995
64
Dec 15, 2016
Dec 15, 2016
65
int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v);
66
67
Set the value of the attribute named attr_name, for object 'o',
68
to the value 'v'. Raise an exception and return -1 on failure; return 0 on
69
success.
Jul 18, 1995
Jul 18, 1995
70
Dec 15, 2016
Dec 15, 2016
71
This is the equivalent of the Python statement o.attr_name=v. */
Jul 18, 1995
Jul 18, 1995
72
73
Dec 6, 2016
Dec 6, 2016
74
/* Implemented elsewhere:
Jul 18, 1995
Jul 18, 1995
75
Dec 15, 2016
Dec 15, 2016
76
int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v);
Jul 18, 1995
Jul 18, 1995
77
Dec 15, 2016
Dec 15, 2016
78
Set the value of the attribute named attr_name, for object 'o', to the value
79
'v'. an exception and return -1 on failure; return 0 on success.
Jul 18, 1995
Jul 18, 1995
80
Dec 15, 2016
Dec 15, 2016
81
This is the equivalent of the Python statement o.attr_name=v. */
Jul 18, 1995
Jul 18, 1995
82
Dec 15, 2016
Dec 15, 2016
83
/* Implemented as a macro:
Jul 18, 1995
Jul 18, 1995
84
Dec 15, 2016
Dec 15, 2016
85
int PyObject_DelAttrString(PyObject *o, const char *attr_name);
Jul 18, 1995
Jul 18, 1995
86
Dec 15, 2016
Dec 15, 2016
87
Delete attribute named attr_name, for object o. Returns
88
-1 on failure.
Jul 18, 1995
Jul 18, 1995
89
Dec 15, 2016
Dec 15, 2016
90
This is the equivalent of the Python statement: del o.attr_name. */
Jun 20, 2022
Jun 20, 2022
91
#define PyObject_DelAttrString(O, A) PyObject_SetAttrString((O), (A), NULL)
Jul 18, 1995
Jul 18, 1995
92
93
Dec 15, 2016
Dec 15, 2016
94
/* Implemented as a macro:
Jul 18, 1995
Jul 18, 1995
95
Dec 15, 2016
Dec 15, 2016
96
int PyObject_DelAttr(PyObject *o, PyObject *attr_name);
97
98
Delete attribute named attr_name, for object o. Returns -1
99
on failure. This is the equivalent of the Python
100
statement: del o.attr_name. */
Jun 20, 2022
Jun 20, 2022
101
#define PyObject_DelAttr(O, A) PyObject_SetAttr((O), (A), NULL)
Jul 18, 1995
Jul 18, 1995
102
103
Dec 6, 2016
Dec 6, 2016
104
/* Implemented elsewhere:
Jul 18, 1995
Jul 18, 1995
105
Dec 15, 2016
Dec 15, 2016
106
PyObject *PyObject_Repr(PyObject *o);
107
108
Compute the string representation of object 'o'. Returns the
109
string representation on success, NULL on failure.
Jul 18, 1995
Jul 18, 1995
110
Dec 15, 2016
Dec 15, 2016
111
This is the equivalent of the Python expression: repr(o).
Jul 18, 1995
Jul 18, 1995
112
Dec 15, 2016
Dec 15, 2016
113
Called by the repr() built-in function. */
Jul 18, 1995
Jul 18, 1995
114
115
Dec 6, 2016
Dec 6, 2016
116
/* Implemented elsewhere:
Jul 18, 1995
Jul 18, 1995
117
Dec 15, 2016
Dec 15, 2016
118
PyObject *PyObject_Str(PyObject *o);
Jul 18, 1995
Jul 18, 1995
119
Dec 15, 2016
Dec 15, 2016
120
Compute the string representation of object, o. Returns the
121
string representation on success, NULL on failure.
Jul 18, 1995
Jul 18, 1995
122
Dec 15, 2016
Dec 15, 2016
123
This is the equivalent of the Python expression: str(o).
Jan 17, 2001
Jan 17, 2001
124
Dec 15, 2016
Dec 15, 2016
125
Called by the str() and print() built-in functions. */
Jan 17, 2001
Jan 17, 2001
126
Dec 13, 2006
Dec 13, 2006
127
Dec 15, 2016
Dec 15, 2016
128
/* Declared elsewhere
Jul 18, 1995
Jul 18, 1995
129
Dec 15, 2016
Dec 15, 2016
130
PyAPI_FUNC(int) PyCallable_Check(PyObject *o);
131
132
Determine if the object, o, is callable. Return 1 if the object is callable
133
and 0 otherwise.
134
135
This function always succeeds. */
136
137
138
#ifdef PY_SSIZE_T_CLEAN
139
# define PyObject_CallFunction _PyObject_CallFunction_SizeT
140
# define PyObject_CallMethod _PyObject_CallMethod_SizeT
141
#endif
Jul 18, 1995
Jul 18, 1995
142
Dec 6, 2016
Dec 6, 2016
143
Jun 17, 2019
Jun 17, 2019
144
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
145
/* Call a callable Python object without any arguments */
146
PyAPI_FUNC(PyObject *) PyObject_CallNoArgs(PyObject *func);
147
#endif
148
149
Dec 6, 2016
Dec 6, 2016
150
/* Call a callable Python object 'callable' with arguments given by the
151
tuple 'args' and keywords arguments given by the dictionary 'kwargs'.
Jul 18, 1995
Jul 18, 1995
152
Oct 30, 2019
Oct 30, 2019
153
'args' must not be NULL, use an empty tuple if no arguments are
Dec 6, 2016
Dec 6, 2016
154
needed. If no named arguments are needed, 'kwargs' can be NULL.
Aug 2, 2001
Aug 2, 2001
155
Dec 6, 2016
Dec 6, 2016
156
This is the equivalent of the Python expression:
157
callable(*args, **kwargs). */
158
PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable,
159
PyObject *args, PyObject *kwargs);
Dec 6, 2016
Dec 6, 2016
160
161
Dec 6, 2016
Dec 6, 2016
162
/* Call a callable Python object 'callable', with arguments given by the
Oct 30, 2019
Oct 30, 2019
163
tuple 'args'. If no arguments are needed, then 'args' can be NULL.
Dec 6, 2016
Dec 6, 2016
164
Oct 30, 2019
Oct 30, 2019
165
Returns the result of the call on success, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
166
Dec 6, 2016
Dec 6, 2016
167
This is the equivalent of the Python expression:
Dec 15, 2016
Dec 15, 2016
168
callable(*args). */
Dec 6, 2016
Dec 6, 2016
169
PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable,
170
PyObject *args);
Jul 18, 1995
Jul 18, 1995
171
Dec 6, 2016
Dec 6, 2016
172
/* Call a callable Python object, callable, with a variable number of C
173
arguments. The C arguments are described using a mkvalue-style format
174
string.
Dec 6, 2016
Dec 6, 2016
175
Dec 6, 2016
Dec 6, 2016
176
The format may be NULL, indicating that no arguments are provided.
Dec 6, 2016
Dec 6, 2016
177
Dec 6, 2016
Dec 6, 2016
178
Returns the result of the call on success, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
179
Dec 6, 2016
Dec 6, 2016
180
This is the equivalent of the Python expression:
Dec 15, 2016
Dec 15, 2016
181
callable(arg1, arg2, ...). */
Dec 6, 2016
Dec 6, 2016
182
PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable,
183
const char *format, ...);
Jul 18, 1995
Jul 18, 1995
184
Dec 6, 2016
Dec 6, 2016
185
/* Call the method named 'name' of object 'obj' with a variable number of
186
C arguments. The C arguments are described by a mkvalue format string.
Jul 18, 1995
Jul 18, 1995
187
Dec 6, 2016
Dec 6, 2016
188
The format can be NULL, indicating that no arguments are provided.
Jul 18, 1995
Jul 18, 1995
189
Dec 6, 2016
Dec 6, 2016
190
Returns the result of the call on success, or NULL on failure.
191
192
This is the equivalent of the Python expression:
Dec 15, 2016
Dec 15, 2016
193
obj.name(arg1, arg2, ...). */
Dec 6, 2016
Dec 6, 2016
194
PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *obj,
195
const char *name,
196
const char *format, ...);
Oct 26, 2001
Oct 26, 2001
197
Dec 6, 2016
Dec 6, 2016
198
PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable,
199
const char *format,
200
...);
201
202
PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *obj,
203
const char *name,
204
const char *format,
205
...);
206
207
/* Call a callable Python object 'callable' with a variable number of C
208
arguments. The C arguments are provided as PyObject* values, terminated
209
by a NULL.
Dec 6, 2016
Dec 6, 2016
210
Dec 6, 2016
Dec 6, 2016
211
Returns the result of the call on success, or NULL on failure.
Dec 6, 2016
Dec 6, 2016
212
Dec 6, 2016
Dec 6, 2016
213
This is the equivalent of the Python expression:
Dec 15, 2016
Dec 15, 2016
214
callable(arg1, arg2, ...). */
Dec 6, 2016
Dec 6, 2016
215
PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable,
216
...);
Oct 26, 2001
Oct 26, 2001
217
Dec 15, 2016
Dec 15, 2016
218
/* Call the method named 'name' of object 'obj' with a variable number of
219
C arguments. The C arguments are provided as PyObject* values, terminated
220
by NULL.
221
222
Returns the result of the call on success, or NULL on failure.
223
224
This is the equivalent of the Python expression: obj.name(*args). */
Dec 6, 2016
Dec 6, 2016
225
226
PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(
227
PyObject *obj,
228
PyObject *name,
229
...);
Jul 18, 1995
Jul 18, 1995
230
Aug 8, 2022
Aug 8, 2022
231
/* Given a vectorcall nargsf argument, return the actual number of arguments.
232
* (For use outside the limited API, this is re-defined as a static inline
233
* function in cpython/abstract.h)
234
*/
235
PyAPI_FUNC(Py_ssize_t) PyVectorcall_NARGS(size_t nargsf);
236
237
/* Call "callable" (which must support vectorcall) with positional arguments
238
"tuple" and keyword arguments "dict". "dict" may also be NULL */
239
PyAPI_FUNC(PyObject *) PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict);
240
Oct 27, 2022
Oct 27, 2022
241
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000
242
#define PY_VECTORCALL_ARGUMENTS_OFFSET \
243
(_Py_STATIC_CAST(size_t, 1) << (8 * sizeof(size_t) - 1))
244
245
/* Perform a PEP 590-style vector call on 'callable' */
246
PyAPI_FUNC(PyObject *) PyObject_Vectorcall(
247
PyObject *callable,
248
PyObject *const *args,
249
size_t nargsf,
250
PyObject *kwnames);
251
252
/* Call the method 'name' on args[0] with arguments in args[1..nargsf-1]. */
253
PyAPI_FUNC(PyObject *) PyObject_VectorcallMethod(
254
PyObject *name, PyObject *const *args,
255
size_t nargsf, PyObject *kwnames);
256
#endif
Jul 18, 1995
Jul 18, 1995
257
Dec 6, 2016
Dec 6, 2016
258
/* Implemented elsewhere:
Jul 18, 1995
Jul 18, 1995
259
Dec 16, 2017
Dec 16, 2017
260
Py_hash_t PyObject_Hash(PyObject *o);
Jul 18, 1995
Jul 18, 1995
261
Dec 15, 2016
Dec 15, 2016
262
Compute and return the hash, hash_value, of an object, o. On
263
failure, return -1.
264
265
This is the equivalent of the Python expression: hash(o). */
Jul 18, 1995
Jul 18, 1995
266
267
Dec 6, 2016
Dec 6, 2016
268
/* Implemented elsewhere:
Jul 18, 1995
Jul 18, 1995
269
Dec 15, 2016
Dec 15, 2016
270
int PyObject_IsTrue(PyObject *o);
271
272
Returns 1 if the object, o, is considered to be true, 0 if o is
273
considered to be false and -1 on failure.
274
275
This is equivalent to the Python expression: not not o. */
Jul 18, 1995
Jul 18, 1995
276
277
Dec 6, 2016
Dec 6, 2016
278
/* Implemented elsewhere:
Apr 9, 1998
Apr 9, 1998
279
Dec 15, 2016
Dec 15, 2016
280
int PyObject_Not(PyObject *o);
281
282
Returns 0 if the object, o, is considered to be true, 1 if o is
283
considered to be false and -1 on failure.
Apr 9, 1998
Apr 9, 1998
284
Dec 15, 2016
Dec 15, 2016
285
This is equivalent to the Python expression: not o. */
Apr 9, 1998
Apr 9, 1998
286
Dec 15, 2016
Dec 15, 2016
287
288
/* Get the type of an object.
289
290
On success, returns a type object corresponding to the object type of object
291
'o'. On failure, returns NULL.
292
293
This is equivalent to the Python expression: type(o) */
Dec 6, 2016
Dec 6, 2016
294
PyAPI_FUNC(PyObject *) PyObject_Type(PyObject *o);
Jul 18, 1995
Jul 18, 1995
295
296
Dec 15, 2016
Dec 15, 2016
297
/* Return the size of object 'o'. If the object 'o' provides both sequence and
298
mapping protocols, the sequence size is returned.
299
300
On error, -1 is returned.
301
302
This is the equivalent to the Python expression: len(o) */
Dec 6, 2016
Dec 6, 2016
303
PyAPI_FUNC(Py_ssize_t) PyObject_Size(PyObject *o);
Jul 12, 2000
Jul 12, 2000
304
Jul 18, 1995
Jul 18, 1995
305
Dec 6, 2016
Dec 6, 2016
306
/* For DLL compatibility */
Jul 17, 2000
Jul 17, 2000
307
#undef PyObject_Length
Dec 6, 2016
Dec 6, 2016
308
PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o);
Jul 17, 2000
Jul 17, 2000
309
#define PyObject_Length PyObject_Size
310
Dec 15, 2016
Dec 15, 2016
311
/* Return element of 'o' corresponding to the object 'key'. Return NULL
312
on failure.
Jul 18, 1995
Jul 18, 1995
313
Dec 15, 2016
Dec 15, 2016
314
This is the equivalent of the Python expression: o[key] */
Dec 6, 2016
Dec 6, 2016
315
PyAPI_FUNC(PyObject *) PyObject_GetItem(PyObject *o, PyObject *key);
Jan 5, 2002
Jan 5, 2002
316
Aug 21, 1996
Aug 21, 1996
317
Dec 15, 2016
Dec 15, 2016
318
/* Map the object 'key' to the value 'v' into 'o'.
319
320
Raise an exception and return -1 on failure; return 0 on success.
321
322
This is the equivalent of the Python statement: o[key]=v. */
Dec 6, 2016
Dec 6, 2016
323
PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v);
Aug 21, 1996
Aug 21, 1996
324
May 22, 2018
May 22, 2018
325
/* Remove the mapping for the string 'key' from the object 'o'.
Dec 15, 2016
Dec 15, 2016
326
Returns -1 on failure.
Aug 18, 2007
Aug 18, 2007
327
Dec 15, 2016
Dec 15, 2016
328
This is equivalent to the Python statement: del o[key]. */
Dec 6, 2016
Dec 6, 2016
329
PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, const char *key);
Mar 10, 2000
Mar 10, 2000
330
May 22, 2018
May 22, 2018
331
/* Delete the mapping for the object 'key' from the object 'o'.
332
Returns -1 on failure.
Mar 10, 2000
Mar 10, 2000
333
Dec 15, 2016
Dec 15, 2016
334
This is the equivalent of the Python statement: del o[key]. */
Dec 6, 2016
Dec 6, 2016
335
PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key);
Nov 9, 2001
Nov 9, 2001
336
337
Jul 29, 2021
Jul 29, 2021
338
/* === Old Buffer API ============================================ */
339
340
/* FIXME: usage of these should all be replaced in Python itself
341
but for backwards compatibility we will implement them.
342
Their usage without a corresponding "unlock" mechanism
343
may create issues (but they would already be there). */
344
345
/* Takes an arbitrary object which must support the (character, single segment)
346
buffer interface and returns a pointer to a read-only memory location
Oct 6, 2021
Oct 6, 2021
347
usable as character based input for subsequent processing.
Jul 29, 2021
Jul 29, 2021
348
349
Return 0 on success. buffer and buffer_len are only set in case no error
350
occurs. Otherwise, -1 is returned and an exception set. */
351
Py_DEPRECATED(3.0)
352
PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj,
353
const char **buffer,
354
Py_ssize_t *buffer_len);
355
356
/* Checks whether an arbitrary object supports the (character, single segment)
357
buffer interface.
358
359
Returns 1 on success, 0 on failure. */
360
Py_DEPRECATED(3.0) PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj);
361
362
/* Same as PyObject_AsCharBuffer() except that this API expects (readable,
363
single segment) buffer interface and returns a pointer to a read-only memory
364
location which can contain arbitrary data.
365
366
0 is returned on success. buffer and buffer_len are only set in case no
367
error occurs. Otherwise, -1 is returned and an exception set. */
368
Py_DEPRECATED(3.0)
369
PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
370
const void **buffer,
371
Py_ssize_t *buffer_len);
372
373
/* Takes an arbitrary object which must support the (writable, single segment)
374
buffer interface and returns a pointer to a writable memory location in
375
buffer of size 'buffer_len'.
376
377
Return 0 on success. buffer and buffer_len are only set in case no error
378
occurs. Otherwise, -1 is returned and an exception set. */
379
Py_DEPRECATED(3.0)
380
PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj,
381
void **buffer,
382
Py_ssize_t *buffer_len);
383
384
Dec 15, 2016
Dec 15, 2016
385
/* === New Buffer API ============================================ */
Aug 18, 2007
Aug 18, 2007
386
Dec 15, 2016
Dec 15, 2016
387
/* Takes an arbitrary object and returns the result of calling
388
obj.__format__(format_spec). */
389
PyAPI_FUNC(PyObject *) PyObject_Format(PyObject *obj,
Dec 6, 2016
Dec 6, 2016
390
PyObject *format_spec);
Feb 17, 2008
Feb 17, 2008
391
Apr 23, 2001
Apr 23, 2001
392
Dec 15, 2016
Dec 15, 2016
393
/* ==== Iterators ================================================ */
394
395
/* Takes an object and returns an iterator for it.
396
This is typically a new iterator but if the argument is an iterator, this
397
returns itself. */
Dec 6, 2016
Dec 6, 2016
398
PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *);
Apr 20, 2001
Apr 20, 2001
399
Mar 23, 2021
Mar 23, 2021
400
/* Takes an AsyncIterable object and returns an AsyncIterator for it.
401
This is typically a new iterator but if the argument is an AsyncIterator,
402
this returns itself. */
Sep 7, 2021
Sep 7, 2021
403
PyAPI_FUNC(PyObject *) PyObject_GetAIter(PyObject *);
Mar 23, 2021
Mar 23, 2021
404
Feb 16, 2021
Feb 16, 2021
405
/* Returns non-zero if the object 'obj' provides iterator protocols, and 0 otherwise.
Jun 9, 2018
Jun 9, 2018
406
407
This function always succeeds. */
Jun 11, 2018
Jun 11, 2018
408
PyAPI_FUNC(int) PyIter_Check(PyObject *);
Apr 23, 2001
Apr 23, 2001
409
Mar 23, 2021
Mar 23, 2021
410
/* Returns non-zero if the object 'obj' provides AsyncIterator protocols, and 0 otherwise.
411
412
This function always succeeds. */
Sep 7, 2021
Sep 7, 2021
413
PyAPI_FUNC(int) PyAIter_Check(PyObject *);
Mar 23, 2021
Mar 23, 2021
414
Dec 15, 2016
Dec 15, 2016
415
/* Takes an iterator object and calls its tp_iternext slot,
416
returning the next value.
417
418
If the iterator is exhausted, this returns NULL without setting an
419
exception.
420
421
NULL with an exception means an error occurred. */
Dec 6, 2016
Dec 6, 2016
422
PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *);
Apr 23, 2001
Apr 23, 2001
423
Oct 13, 2020
Oct 13, 2020
424
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000
Oct 10, 2020
Oct 10, 2020
425
426
/* Takes generator, coroutine or iterator object and sends the value into it.
427
Returns:
428
- PYGEN_RETURN (0) if generator has returned.
429
'result' parameter is filled with return value
430
- PYGEN_ERROR (-1) if exception was raised.
431
'result' parameter is NULL
432
- PYGEN_NEXT (1) if generator has yielded.
433
'result' parameter is filled with yielded value. */
434
PyAPI_FUNC(PySendResult) PyIter_Send(PyObject *, PyObject *, PyObject **);
Oct 13, 2020
Oct 13, 2020
435
#endif
Oct 10, 2020
Oct 10, 2020
436
Jul 18, 1995
Jul 18, 1995
437
Dec 6, 2016
Dec 6, 2016
438
/* === Number Protocol ================================================== */
Jul 18, 1995
Jul 18, 1995
439
Dec 15, 2016
Dec 15, 2016
440
/* Returns 1 if the object 'o' provides numeric protocols, and 0 otherwise.
Jul 18, 1995
Jul 18, 1995
441
Dec 15, 2016
Dec 15, 2016
442
This function always succeeds. */
443
PyAPI_FUNC(int) PyNumber_Check(PyObject *o);
Jul 18, 1995
Jul 18, 1995
444
Dec 15, 2016
Dec 15, 2016
445
/* Returns the result of adding o1 and o2, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
446
Dec 15, 2016
Dec 15, 2016
447
This is the equivalent of the Python expression: o1 + o2. */
Dec 6, 2016
Dec 6, 2016
448
PyAPI_FUNC(PyObject *) PyNumber_Add(PyObject *o1, PyObject *o2);
Jul 18, 1995
Jul 18, 1995
449
Dec 15, 2016
Dec 15, 2016
450
/* Returns the result of subtracting o2 from o1, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
451
Dec 15, 2016
Dec 15, 2016
452
This is the equivalent of the Python expression: o1 - o2. */
Dec 6, 2016
Dec 6, 2016
453
PyAPI_FUNC(PyObject *) PyNumber_Subtract(PyObject *o1, PyObject *o2);
Jul 18, 1995
Jul 18, 1995
454
Dec 15, 2016
Dec 15, 2016
455
/* Returns the result of multiplying o1 and o2, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
456
Dec 15, 2016
Dec 15, 2016
457
This is the equivalent of the Python expression: o1 * o2. */
Dec 6, 2016
Dec 6, 2016
458
PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2);
Jul 18, 1995
Jul 18, 1995
459
Dec 27, 2016
Dec 27, 2016
460
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
Dec 15, 2016
Dec 15, 2016
461
/* This is the equivalent of the Python expression: o1 @ o2. */
Dec 6, 2016
Dec 6, 2016
462
PyAPI_FUNC(PyObject *) PyNumber_MatrixMultiply(PyObject *o1, PyObject *o2);
Dec 27, 2016
Dec 27, 2016
463
#endif
Apr 10, 2014
Apr 10, 2014
464
Dec 15, 2016
Dec 15, 2016
465
/* Returns the result of dividing o1 by o2 giving an integral result,
466
or NULL on failure.
Aug 8, 2001
Aug 8, 2001
467
Dec 15, 2016
Dec 15, 2016
468
This is the equivalent of the Python expression: o1 // o2. */
Dec 6, 2016
Dec 6, 2016
469
PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2);
Aug 8, 2001
Aug 8, 2001
470
Dec 15, 2016
Dec 15, 2016
471
/* Returns the result of dividing o1 by o2 giving a float result, or NULL on
472
failure.
Aug 8, 2001
Aug 8, 2001
473
Dec 15, 2016
Dec 15, 2016
474
This is the equivalent of the Python expression: o1 / o2. */
Dec 6, 2016
Dec 6, 2016
475
PyAPI_FUNC(PyObject *) PyNumber_TrueDivide(PyObject *o1, PyObject *o2);
Aug 8, 2001
Aug 8, 2001
476
Dec 15, 2016
Dec 15, 2016
477
/* Returns the remainder of dividing o1 by o2, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
478
Dec 15, 2016
Dec 15, 2016
479
This is the equivalent of the Python expression: o1 % o2. */
Dec 6, 2016
Dec 6, 2016
480
PyAPI_FUNC(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2);
Jul 18, 1995
Jul 18, 1995
481
Dec 15, 2016
Dec 15, 2016
482
/* See the built-in function divmod.
Jul 18, 1995
Jul 18, 1995
483
Dec 15, 2016
Dec 15, 2016
484
Returns NULL on failure.
485
486
This is the equivalent of the Python expression: divmod(o1, o2). */
Dec 6, 2016
Dec 6, 2016
487
PyAPI_FUNC(PyObject *) PyNumber_Divmod(PyObject *o1, PyObject *o2);
Jul 18, 1995
Jul 18, 1995
488
Dec 15, 2016
Dec 15, 2016
489
/* See the built-in function pow. Returns NULL on failure.
Jul 18, 1995
Jul 18, 1995
490
Dec 15, 2016
Dec 15, 2016
491
This is the equivalent of the Python expression: pow(o1, o2, o3),
492
where o3 is optional. */
Dec 6, 2016
Dec 6, 2016
493
PyAPI_FUNC(PyObject *) PyNumber_Power(PyObject *o1, PyObject *o2,
494
PyObject *o3);
Jul 18, 1995
Jul 18, 1995
495
Dec 15, 2016
Dec 15, 2016
496
/* Returns the negation of o on success, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
497
Dec 15, 2016
Dec 15, 2016
498
This is the equivalent of the Python expression: -o. */
Dec 6, 2016
Dec 6, 2016
499
PyAPI_FUNC(PyObject *) PyNumber_Negative(PyObject *o);
Jul 18, 1995
Jul 18, 1995
500
Dec 15, 2016
Dec 15, 2016
501
/* Returns the positive of o on success, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
502
Dec 15, 2016
Dec 15, 2016
503
This is the equivalent of the Python expression: +o. */
Dec 6, 2016
Dec 6, 2016
504
PyAPI_FUNC(PyObject *) PyNumber_Positive(PyObject *o);
Jul 18, 1995
Jul 18, 1995
505
Dec 15, 2016
Dec 15, 2016
506
/* Returns the absolute value of 'o', or NULL on failure.
Jul 18, 1995
Jul 18, 1995
507
Dec 15, 2016
Dec 15, 2016
508
This is the equivalent of the Python expression: abs(o). */
Dec 6, 2016
Dec 6, 2016
509
PyAPI_FUNC(PyObject *) PyNumber_Absolute(PyObject *o);
Jul 18, 1995
Jul 18, 1995
510
Dec 15, 2016
Dec 15, 2016
511
/* Returns the bitwise negation of 'o' on success, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
512
Dec 15, 2016
Dec 15, 2016
513
This is the equivalent of the Python expression: ~o. */
Dec 6, 2016
Dec 6, 2016
514
PyAPI_FUNC(PyObject *) PyNumber_Invert(PyObject *o);
Jul 18, 1995
Jul 18, 1995
515
Dec 15, 2016
Dec 15, 2016
516
/* Returns the result of left shifting o1 by o2 on success, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
517
Dec 15, 2016
Dec 15, 2016
518
This is the equivalent of the Python expression: o1 << o2. */
Dec 6, 2016
Dec 6, 2016
519
PyAPI_FUNC(PyObject *) PyNumber_Lshift(PyObject *o1, PyObject *o2);
Jul 18, 1995
Jul 18, 1995
520
Dec 15, 2016
Dec 15, 2016
521
/* Returns the result of right shifting o1 by o2 on success, or NULL on
522
failure.
Jul 18, 1995
Jul 18, 1995
523
Dec 15, 2016
Dec 15, 2016
524
This is the equivalent of the Python expression: o1 >> o2. */
Dec 6, 2016
Dec 6, 2016
525
PyAPI_FUNC(PyObject *) PyNumber_Rshift(PyObject *o1, PyObject *o2);
Jul 18, 1995
Jul 18, 1995
526
Dec 15, 2016
Dec 15, 2016
527
/* Returns the result of bitwise and of o1 and o2 on success, or NULL on
528
failure.
Jul 18, 1995
Jul 18, 1995
529
Dec 15, 2016
Dec 15, 2016
530
This is the equivalent of the Python expression: o1 & o2. */
Dec 6, 2016
Dec 6, 2016
531
PyAPI_FUNC(PyObject *) PyNumber_And(PyObject *o1, PyObject *o2);
Jul 18, 1995
Jul 18, 1995
532
Dec 15, 2016
Dec 15, 2016
533
/* Returns the bitwise exclusive or of o1 by o2 on success, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
534
Dec 15, 2016
Dec 15, 2016
535
This is the equivalent of the Python expression: o1 ^ o2. */
Dec 6, 2016
Dec 6, 2016
536
PyAPI_FUNC(PyObject *) PyNumber_Xor(PyObject *o1, PyObject *o2);
Jul 18, 1995
Jul 18, 1995
537
Dec 15, 2016
Dec 15, 2016
538
/* Returns the result of bitwise or on o1 and o2 on success, or NULL on
539
failure.
Jul 18, 1995
Jul 18, 1995
540
Dec 15, 2016
Dec 15, 2016
541
This is the equivalent of the Python expression: o1 | o2. */
Dec 6, 2016
Dec 6, 2016
542
PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2);
543
Jun 9, 2018
Jun 9, 2018
544
/* Returns 1 if obj is an index integer (has the nb_index slot of the
545
tp_as_number structure filled in), and 0 otherwise. */
Jun 11, 2018
Jun 11, 2018
546
PyAPI_FUNC(int) PyIndex_Check(PyObject *);
May 9, 2010
May 9, 2010
547
Dec 15, 2016
Dec 15, 2016
548
/* Returns the object 'o' converted to a Python int, or NULL with an exception
549
raised on failure. */
Dec 6, 2016
Dec 6, 2016
550
PyAPI_FUNC(PyObject *) PyNumber_Index(PyObject *o);
Mar 7, 2006
Mar 7, 2006
551
Dec 15, 2016
Dec 15, 2016
552
/* Returns the object 'o' converted to Py_ssize_t by going through
553
PyNumber_Index() first.
Mar 7, 2006
Mar 7, 2006
554
Dec 15, 2016
Dec 15, 2016
555
If an overflow error occurs while converting the int to Py_ssize_t, then the
556
second argument 'exc' is the error-type to return. If it is NULL, then the
557
overflow error is cleared and the value is clipped. */
Dec 6, 2016
Dec 6, 2016
558
PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc);
Aug 21, 2006
Aug 21, 2006
559
Dec 15, 2016
Dec 15, 2016
560
/* Returns the object 'o' converted to an integer object on success, or NULL
561
on failure.
Mar 7, 2006
Mar 7, 2006
562
Dec 15, 2016
Dec 15, 2016
563
This is the equivalent of the Python expression: int(o). */
Dec 6, 2016
Dec 6, 2016
564
PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o);
Jan 10, 2009
Jan 10, 2009
565
Dec 15, 2016
Dec 15, 2016
566
/* Returns the object 'o' converted to a float object on success, or NULL
567
on failure.
Jul 18, 1995
Jul 18, 1995
568
Dec 15, 2016
Dec 15, 2016
569
This is the equivalent of the Python expression: float(o). */
Dec 6, 2016
Dec 6, 2016
570
PyAPI_FUNC(PyObject *) PyNumber_Float(PyObject *o);
571
Jul 18, 1995
Jul 18, 1995
572
Dec 15, 2016
Dec 15, 2016
573
/* --- In-place variants of (some of) the above number protocol functions -- */
May 9, 2010
May 9, 2010
574
Dec 15, 2016
Dec 15, 2016
575
/* Returns the result of adding o2 to o1, possibly in-place, or NULL
576
on failure.
Aug 24, 2000
Aug 24, 2000
577
Dec 15, 2016
Dec 15, 2016
578
This is the equivalent of the Python expression: o1 += o2. */
Dec 6, 2016
Dec 6, 2016
579
PyAPI_FUNC(PyObject *) PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2);
Aug 24, 2000
Aug 24, 2000
580
Dec 15, 2016
Dec 15, 2016
581
/* Returns the result of subtracting o2 from o1, possibly in-place or
582
NULL on failure.
Aug 24, 2000
Aug 24, 2000
583
Dec 15, 2016
Dec 15, 2016
584
This is the equivalent of the Python expression: o1 -= o2. */
Dec 6, 2016
Dec 6, 2016
585
PyAPI_FUNC(PyObject *) PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2);
Aug 24, 2000
Aug 24, 2000
586
Dec 15, 2016
Dec 15, 2016
587
/* Returns the result of multiplying o1 by o2, possibly in-place, or NULL on
588
failure.
Aug 24, 2000
Aug 24, 2000
589
Dec 15, 2016
Dec 15, 2016
590
This is the equivalent of the Python expression: o1 *= o2. */
Dec 6, 2016
Dec 6, 2016
591
PyAPI_FUNC(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2);
Aug 24, 2000
Aug 24, 2000
592
Dec 27, 2016
Dec 27, 2016
593
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
Dec 15, 2016
Dec 15, 2016
594
/* This is the equivalent of the Python expression: o1 @= o2. */
Dec 6, 2016
Dec 6, 2016
595
PyAPI_FUNC(PyObject *) PyNumber_InPlaceMatrixMultiply(PyObject *o1, PyObject *o2);
Dec 27, 2016
Dec 27, 2016
596
#endif
Apr 10, 2014
Apr 10, 2014
597
Dec 15, 2016
Dec 15, 2016
598
/* Returns the result of dividing o1 by o2 giving an integral result, possibly
599
in-place, or NULL on failure.
Apr 10, 2014
Apr 10, 2014
600
Dec 15, 2016
Dec 15, 2016
601
This is the equivalent of the Python expression: o1 /= o2. */
Dec 6, 2016
Dec 6, 2016
602
PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1,
603
PyObject *o2);
Aug 8, 2001
Aug 8, 2001
604
Dec 15, 2016
Dec 15, 2016
605
/* Returns the result of dividing o1 by o2 giving a float result, possibly
606
in-place, or null on failure.
Aug 8, 2001
Aug 8, 2001
607
Dec 15, 2016
Dec 15, 2016
608
This is the equivalent of the Python expression: o1 /= o2. */
Dec 6, 2016
Dec 6, 2016
609
PyAPI_FUNC(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1,
610
PyObject *o2);
Aug 8, 2001
Aug 8, 2001
611
Dec 15, 2016
Dec 15, 2016
612
/* Returns the remainder of dividing o1 by o2, possibly in-place, or NULL on
613
failure.
Aug 8, 2001
Aug 8, 2001
614
Dec 15, 2016
Dec 15, 2016
615
This is the equivalent of the Python expression: o1 %= o2. */
Dec 6, 2016
Dec 6, 2016
616
PyAPI_FUNC(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2);
Aug 24, 2000
Aug 24, 2000
617
Dec 15, 2016
Dec 15, 2016
618
/* Returns the result of raising o1 to the power of o2, possibly in-place,
619
or NULL on failure.
Aug 24, 2000
Aug 24, 2000
620
Dec 15, 2016
Dec 15, 2016
621
This is the equivalent of the Python expression: o1 **= o2,
622
or o1 = pow(o1, o2, o3) if o3 is present. */
Dec 6, 2016
Dec 6, 2016
623
PyAPI_FUNC(PyObject *) PyNumber_InPlacePower(PyObject *o1, PyObject *o2,
624
PyObject *o3);
Aug 24, 2000
Aug 24, 2000
625
Dec 15, 2016
Dec 15, 2016
626
/* Returns the result of left shifting o1 by o2, possibly in-place, or NULL
627
on failure.
Aug 24, 2000
Aug 24, 2000
628
Dec 15, 2016
Dec 15, 2016
629
This is the equivalent of the Python expression: o1 <<= o2. */
Dec 6, 2016
Dec 6, 2016
630
PyAPI_FUNC(PyObject *) PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2);
Aug 24, 2000
Aug 24, 2000
631
Dec 15, 2016
Dec 15, 2016
632
/* Returns the result of right shifting o1 by o2, possibly in-place or NULL
633
on failure.
Aug 24, 2000
Aug 24, 2000
634
Dec 15, 2016
Dec 15, 2016
635
This is the equivalent of the Python expression: o1 >>= o2. */
Dec 6, 2016
Dec 6, 2016
636
PyAPI_FUNC(PyObject *) PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2);
Aug 24, 2000
Aug 24, 2000
637
Dec 15, 2016
Dec 15, 2016
638
/* Returns the result of bitwise and of o1 and o2, possibly in-place, or NULL
639
on failure.
Aug 24, 2000
Aug 24, 2000
640
Dec 15, 2016
Dec 15, 2016
641
This is the equivalent of the Python expression: o1 &= o2. */
Dec 6, 2016
Dec 6, 2016
642
PyAPI_FUNC(PyObject *) PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2);
Aug 24, 2000
Aug 24, 2000
643
Dec 15, 2016
Dec 15, 2016
644
/* Returns the bitwise exclusive or of o1 by o2, possibly in-place, or NULL
645
on failure.
Aug 24, 2000
Aug 24, 2000
646
Dec 15, 2016
Dec 15, 2016
647
This is the equivalent of the Python expression: o1 ^= o2. */
Dec 6, 2016
Dec 6, 2016
648
PyAPI_FUNC(PyObject *) PyNumber_InPlaceXor(PyObject *o1, PyObject *o2);
Aug 24, 2000
Aug 24, 2000
649
Dec 15, 2016
Dec 15, 2016
650
/* Returns the result of bitwise or of o1 and o2, possibly in-place,
651
or NULL on failure.
Aug 24, 2000
Aug 24, 2000
652
Dec 15, 2016
Dec 15, 2016
653
This is the equivalent of the Python expression: o1 |= o2. */
Dec 6, 2016
Dec 6, 2016
654
PyAPI_FUNC(PyObject *) PyNumber_InPlaceOr(PyObject *o1, PyObject *o2);
Aug 24, 2000
Aug 24, 2000
655
Dec 15, 2016
Dec 15, 2016
656
/* Returns the integer n converted to a string with a base, with a base
657
marker of 0b, 0o or 0x prefixed if applicable.
Aug 24, 2000
Aug 24, 2000
658
Dec 15, 2016
Dec 15, 2016
659
If n is not an int object, it is converted with PyNumber_Index first. */
Dec 6, 2016
Dec 6, 2016
660
PyAPI_FUNC(PyObject *) PyNumber_ToBase(PyObject *n, int base);
Jun 13, 2007
Jun 13, 2007
661
Jul 18, 1995
Jul 18, 1995
662
Dec 6, 2016
Dec 6, 2016
663
/* === Sequence protocol ================================================ */
Jul 18, 1995
Jul 18, 1995
664
Dec 15, 2016
Dec 15, 2016
665
/* Return 1 if the object provides sequence protocol, and zero
666
otherwise.
Jul 18, 1995
Jul 18, 1995
667
Dec 15, 2016
Dec 15, 2016
668
This function always succeeds. */
669
PyAPI_FUNC(int) PySequence_Check(PyObject *o);
Jul 18, 1995
Jul 18, 1995
670
Dec 15, 2016
Dec 15, 2016
671
/* Return the size of sequence object o, or -1 on failure. */
Dec 6, 2016
Dec 6, 2016
672
PyAPI_FUNC(Py_ssize_t) PySequence_Size(PyObject *o);
Jul 12, 2000
Jul 12, 2000
673
Dec 6, 2016
Dec 6, 2016
674
/* For DLL compatibility */
Jul 17, 2000
Jul 17, 2000
675
#undef PySequence_Length
Dec 15, 2016
Dec 15, 2016
676
PyAPI_FUNC(Py_ssize_t) PySequence_Length(PyObject *o);
Jul 17, 2000
Jul 17, 2000
677
#define PySequence_Length PySequence_Size
678
679
Dec 15, 2016
Dec 15, 2016
680
/* Return the concatenation of o1 and o2 on success, and NULL on failure.
681
682
This is the equivalent of the Python expression: o1 + o2. */
Dec 6, 2016
Dec 6, 2016
683
PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2);
Jul 18, 1995
Jul 18, 1995
684
Dec 15, 2016
Dec 15, 2016
685
/* Return the result of repeating sequence object 'o' 'count' times,
686
or NULL on failure.
Jul 18, 1995
Jul 18, 1995
687
Dec 15, 2016
Dec 15, 2016
688
This is the equivalent of the Python expression: o * count. */
Dec 6, 2016
Dec 6, 2016
689
PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, Py_ssize_t count);
Jul 18, 1995
Jul 18, 1995
690
Dec 15, 2016
Dec 15, 2016
691
/* Return the ith element of o, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
692
Dec 15, 2016
Dec 15, 2016
693
This is the equivalent of the Python expression: o[i]. */
Dec 6, 2016
Dec 6, 2016
694
PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i);
Jul 18, 1995
Jul 18, 1995
695
Dec 15, 2016
Dec 15, 2016
696
/* Return the slice of sequence object o between i1 and i2, or NULL on failure.
Jul 18, 1995
Jul 18, 1995
697
Dec 15, 2016
Dec 15, 2016
698
This is the equivalent of the Python expression: o[i1:i2]. */
Dec 6, 2016
Dec 6, 2016
699
PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
Jul 18, 1995
Jul 18, 1995
700
Dec 15, 2016
Dec 15, 2016
701
/* Assign object 'v' to the ith element of the sequence 'o'. Raise an exception
702
and return -1 on failure; return 0 on success.
Jul 18, 1995
Jul 18, 1995
703
Dec 15, 2016
Dec 15, 2016
704
This is the equivalent of the Python statement o[i] = v. */
Dec 6, 2016
Dec 6, 2016
705
PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v);
Jul 18, 1995
Jul 18, 1995
706
Dec 15, 2016
Dec 15, 2016
707
/* Delete the 'i'-th element of the sequence 'v'. Returns -1 on failure.
Jul 18, 1995
Jul 18, 1995
708
Dec 15, 2016
Dec 15, 2016
709
This is the equivalent of the Python statement: del o[i]. */
Dec 6, 2016
Dec 6, 2016
710
PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i);
Aug 21, 1996
Aug 21, 1996
711
Dec 15, 2016
Dec 15, 2016
712
/* Assign the sequence object 'v' to the slice in sequence object 'o',
713
from 'i1' to 'i2'. Returns -1 on failure.
Aug 21, 1996
Aug 21, 1996
714
Dec 15, 2016
Dec 15, 2016
715
This is the equivalent of the Python statement: o[i1:i2] = v. */
Dec 6, 2016
Dec 6, 2016
716
PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2,
717
PyObject *v);
Jul 18, 1995
Jul 18, 1995
718
Dec 15, 2016
Dec 15, 2016
719
/* Delete the slice in sequence object 'o' from 'i1' to 'i2'.
720
Returns -1 on failure.
Jul 18, 1995
Jul 18, 1995
721
Dec 15, 2016
Dec 15, 2016
722
This is the equivalent of the Python statement: del o[i1:i2]. */
Dec 6, 2016
Dec 6, 2016
723
PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
Aug 21, 1996
Aug 21, 1996
724
Dec 15, 2016
Dec 15, 2016
725
/* Returns the sequence 'o' as a tuple on success, and NULL on failure.
Aug 21, 1996
Aug 21, 1996
726
Dec 15, 2016
Dec 15, 2016
727
This is equivalent to the Python expression: tuple(o). */
Dec 6, 2016
Dec 6, 2016
728
PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o);
Jul 18, 1995
Jul 18, 1995
729
Dec 15, 2016
Dec 15, 2016
730
/* Returns the sequence 'o' as a list on success, and NULL on failure.
731
This is equivalent to the Python expression: list(o) */
732
PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o);
Jul 18, 1995
Jul 18, 1995
733
Dec 15, 2016
Dec 15, 2016
734
/* Return the sequence 'o' as a list, unless it's already a tuple or list.
Jun 18, 2000
Jun 18, 2000
735
Dec 15, 2016
Dec 15, 2016
736
Use PySequence_Fast_GET_ITEM to access the members of this list, and
737
PySequence_Fast_GET_SIZE to get its length.
Mar 4, 1997
Mar 4, 1997
738
Dec 15, 2016
Dec 15, 2016
739
Returns NULL on failure. If the object does not support iteration, raises a
740
TypeError exception with 'm' as the message text. */
Dec 6, 2016
Dec 6, 2016
741
PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
Jun 18, 2000
Jun 18, 2000
742
Dec 15, 2016
Dec 15, 2016
743
/* Return the size of the sequence 'o', assuming that 'o' was returned by
744
PySequence_Fast and is not NULL. */
Oct 26, 2001
Oct 26, 2001
745
#define PySequence_Fast_GET_SIZE(o) \
May 9, 2010
May 9, 2010
746
(PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o))
Oct 26, 2001
Oct 26, 2001
747
Dec 15, 2016
Dec 15, 2016
748
/* Return the 'i'-th element of the sequence 'o', assuming that o was returned
749
by PySequence_Fast, and that i is within bounds. */
Jun 18, 2000
Jun 18, 2000
750
#define PySequence_Fast_GET_ITEM(o, i)\
Jun 20, 2022
Jun 20, 2022
751
(PyList_Check(o) ? PyList_GET_ITEM((o), (i)) : PyTuple_GET_ITEM((o), (i)))
Jun 18, 2000
Jun 18, 2000
752
Dec 15, 2016
Dec 15, 2016
753
/* Return a pointer to the underlying item array for
Jul 30, 2019
Jul 30, 2019
754
an object returned by PySequence_Fast */
Mar 12, 2004
Mar 12, 2004
755
#define PySequence_Fast_ITEMS(sf) \
May 9, 2010
May 9, 2010
756
(PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \
757
: ((PyTupleObject *)(sf))->ob_item)
Mar 12, 2004
Mar 12, 2004
758
Dec 15, 2016
Dec 15, 2016
759
/* Return the number of occurrences on value on 'o', that is, return
760
the number of keys for which o[key] == value.
761
762
On failure, return -1. This is equivalent to the Python expression:
763
o.count(value). */
Dec 6, 2016
Dec 6, 2016
764
PyAPI_FUNC(Py_ssize_t) PySequence_Count(PyObject *o, PyObject *value);
Jul 18, 1995
Jul 18, 1995
765
Dec 15, 2016
Dec 15, 2016
766
/* Return 1 if 'ob' is in the sequence 'seq'; 0 if 'ob' is not in the sequence
767
'seq'; -1 on error.
Jul 18, 1995
Jul 18, 1995
768
Dec 15, 2016
Dec 15, 2016
769
Use __contains__ if possible, else _PySequence_IterSearch(). */
Dec 6, 2016
Dec 6, 2016
770
PyAPI_FUNC(int) PySequence_Contains(PyObject *seq, PyObject *ob);
Sep 8, 2001
Sep 8, 2001
771
Mar 17, 1999
Mar 17, 1999
772
/* For DLL-level backwards compatibility */
773
#undef PySequence_In
Dec 15, 2016
Dec 15, 2016
774
/* Determine if the sequence 'o' contains 'value'. If an item in 'o' is equal
775
to 'value', return 1, otherwise return 0. On error, return -1.
776
777
This is equivalent to the Python expression: value in o. */
Dec 6, 2016
Dec 6, 2016
778
PyAPI_FUNC(int) PySequence_In(PyObject *o, PyObject *value);
Mar 17, 1999
Mar 17, 1999
779
780
/* For source-level backwards compatibility */
Aug 23, 1998
Aug 23, 1998
781
#define PySequence_In PySequence_Contains
Jul 18, 1995
Jul 18, 1995
782
783
Dec 15, 2016
Dec 15, 2016
784
/* Return the first index for which o[i] == value.
785
On error, return -1.
786
787
This is equivalent to the Python expression: o.index(value). */
Dec 6, 2016
Dec 6, 2016
788
PyAPI_FUNC(Py_ssize_t) PySequence_Index(PyObject *o, PyObject *value);
789
Jul 18, 1995
Jul 18, 1995
790
Dec 15, 2016
Dec 15, 2016
791
/* --- In-place versions of some of the above Sequence functions --- */
Jul 18, 1995
Jul 18, 1995
792
Dec 15, 2016
Dec 15, 2016
793
/* Append sequence 'o2' to sequence 'o1', in-place when possible. Return the
794
resulting object, which could be 'o1', or NULL on failure.
Aug 24, 2000
Aug 24, 2000
795
Dec 15, 2016
Dec 15, 2016
796
This is the equivalent of the Python expression: o1 += o2. */
Dec 6, 2016
Dec 6, 2016
797
PyAPI_FUNC(PyObject *) PySequence_InPlaceConcat(PyObject *o1, PyObject *o2);
Aug 24, 2000
Aug 24, 2000
798
Dec 15, 2016
Dec 15, 2016
799
/* Repeat sequence 'o' by 'count', in-place when possible. Return the resulting
800
object, which could be 'o', or NULL on failure.
Aug 24, 2000
Aug 24, 2000
801
Dec 15, 2016
Dec 15, 2016
802
This is the equivalent of the Python expression: o1 *= count. */
Dec 6, 2016
Dec 6, 2016
803
PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count);
Aug 24, 2000
Aug 24, 2000
804
805
Dec 15, 2016
Dec 15, 2016
806
/* === Mapping protocol ================================================= */
Aug 24, 2000
Aug 24, 2000
807
Dec 15, 2016
Dec 15, 2016
808
/* Return 1 if the object provides mapping protocol, and 0 otherwise.
Jul 18, 1995
Jul 18, 1995
809
Dec 15, 2016
Dec 15, 2016
810
This function always succeeds. */
Dec 6, 2016
Dec 6, 2016
811
PyAPI_FUNC(int) PyMapping_Check(PyObject *o);
Jul 18, 1995
Jul 18, 1995
812
Dec 15, 2016
Dec 15, 2016
813
/* Returns the number of keys in mapping object 'o' on success, and -1 on
May 22, 2018
May 22, 2018
814
failure. This is equivalent to the Python expression: len(o). */
Dec 6, 2016
Dec 6, 2016
815
PyAPI_FUNC(Py_ssize_t) PyMapping_Size(PyObject *o);
Jul 12, 2000
Jul 12, 2000
816
Dec 6, 2016
Dec 6, 2016
817
/* For DLL compatibility */
Jul 17, 2000
Jul 17, 2000
818
#undef PyMapping_Length
Dec 6, 2016
Dec 6, 2016
819
PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o);
Jul 17, 2000
Jul 17, 2000
820
#define PyMapping_Length PyMapping_Size
821
822
Dec 15, 2016
Dec 15, 2016
823
/* Implemented as a macro:
Sep 6, 1996
Sep 6, 1996
824
Dec 15, 2016
Dec 15, 2016
825
int PyMapping_DelItemString(PyObject *o, const char *key);
Jul 18, 1995
Jul 18, 1995
826
May 22, 2018
May 22, 2018
827
Remove the mapping for the string 'key' from the mapping 'o'. Returns -1 on
Dec 15, 2016
Dec 15, 2016
828
failure.
829
830
This is equivalent to the Python statement: del o[key]. */
Jun 20, 2022
Jun 20, 2022
831
#define PyMapping_DelItemString(O, K) PyObject_DelItemString((O), (K))
Sep 6, 1996
Sep 6, 1996
832
Dec 15, 2016
Dec 15, 2016
833
/* Implemented as a macro:
Jul 18, 1995
Jul 18, 1995
834
Dec 15, 2016
Dec 15, 2016
835
int PyMapping_DelItem(PyObject *o, PyObject *key);
Jul 18, 1995
Jul 18, 1995
836
May 22, 2018
May 22, 2018
837
Remove the mapping for the object 'key' from the mapping object 'o'.
Dec 15, 2016
Dec 15, 2016
838
Returns -1 on failure.
Jul 18, 1995
Jul 18, 1995
839
Dec 15, 2016
Dec 15, 2016
840
This is equivalent to the Python statement: del o[key]. */
Jun 20, 2022
Jun 20, 2022
841
#define PyMapping_DelItem(O, K) PyObject_DelItem((O), (K))
Jul 18, 1995
Jul 18, 1995
842
Dec 15, 2016
Dec 15, 2016
843
/* On success, return 1 if the mapping object 'o' has the key 'key',
844
and 0 otherwise.
Jul 18, 1995
Jul 18, 1995
845
Dec 15, 2016
Dec 15, 2016
846
This is equivalent to the Python expression: key in o.
Jul 18, 1995
Jul 18, 1995
847
Dec 15, 2016
Dec 15, 2016
848
This function always succeeds. */
849
PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, const char *key);
Jul 18, 1995
Jul 18, 1995
850
Dec 15, 2016
Dec 15, 2016
851
/* Return 1 if the mapping object has the key 'key', and 0 otherwise.
Jul 18, 1995
Jul 18, 1995
852
Dec 15, 2016
Dec 15, 2016
853
This is equivalent to the Python expression: key in o.
Jul 18, 1995
Jul 18, 1995
854
Dec 15, 2016
Dec 15, 2016
855
This function always succeeds. */
856
PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key);
Jul 18, 1995
Jul 18, 1995
857
Dec 15, 2016
Dec 15, 2016
858
/* On success, return a list or tuple of the keys in mapping object 'o'.
859
On failure, return NULL. */
Dec 6, 2016
Dec 6, 2016
860
PyAPI_FUNC(PyObject *) PyMapping_Keys(PyObject *o);
Jul 18, 1995
Jul 18, 1995
861
Dec 15, 2016
Dec 15, 2016
862
/* On success, return a list or tuple of the values in mapping object 'o'.
863
On failure, return NULL. */
Dec 6, 2016
Dec 6, 2016
864
PyAPI_FUNC(PyObject *) PyMapping_Values(PyObject *o);
Jul 18, 1995
Jul 18, 1995
865
Dec 15, 2016
Dec 15, 2016
866
/* On success, return a list or tuple of the items in mapping object 'o',
867
where each item is a tuple containing a key-value pair. On failure, return
868
NULL. */
Dec 6, 2016
Dec 6, 2016
869
PyAPI_FUNC(PyObject *) PyMapping_Items(PyObject *o);
Jul 18, 1995
Jul 18, 1995
870
May 22, 2018
May 22, 2018
871
/* Return element of 'o' corresponding to the string 'key' or NULL on failure.
Jul 18, 1995
Jul 18, 1995
872
Dec 15, 2016
Dec 15, 2016
873
This is the equivalent of the Python expression: o[key]. */
Dec 6, 2016
Dec 6, 2016
874
PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o,
875
const char *key);
Jul 18, 1995
Jul 18, 1995
876
May 22, 2018
May 22, 2018
877
/* Map the string 'key' to the value 'v' in the mapping 'o'.
Dec 15, 2016
Dec 15, 2016
878
Returns -1 on failure.
Jul 18, 1995
Jul 18, 1995
879
Dec 15, 2016
Dec 15, 2016
880
This is the equivalent of the Python statement: o[key]=v. */
Dec 6, 2016
Dec 6, 2016
881
PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, const char *key,
882
PyObject *value);
Jul 18, 1995
Jul 18, 1995
883
Dec 15, 2016
Dec 15, 2016
884
/* isinstance(object, typeorclass) */
Aug 12, 2002
Aug 12, 2002
885
PyAPI_FUNC(int) PyObject_IsInstance(PyObject *object, PyObject *typeorclass);
Mar 21, 2001
Mar 21, 2001
886
Dec 15, 2016
Dec 15, 2016
887
/* issubclass(object, typeorclass) */
Aug 12, 2002
Aug 12, 2002
888
PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass);
Mar 21, 2001
Mar 21, 2001
889
Dec 3, 2010
Dec 3, 2010
890
#ifndef Py_LIMITED_API
Nov 26, 2018
Nov 26, 2018
891
# define Py_CPYTHON_ABSTRACTOBJECT_H
Oct 14, 2021
Oct 14, 2021
892
# include "cpython/abstract.h"
Nov 26, 2018
Nov 26, 2018
893
# undef Py_CPYTHON_ABSTRACTOBJECT_H
894
#endif
Sep 1, 2010
Sep 1, 2010
895
Sep 18, 1995
Sep 18, 1995
896
#ifdef __cplusplus
897
}
898
#endif
Jul 18, 1995
Jul 18, 1995
899
#endif /* Py_ABSTRACTOBJECT_H */