1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 # include "pycore_runtime.h" // _Py_SINGLETON()
7 #endif
8 #include "pycore_abstract.h" // _PyNumber_Index()
9 #include "pycore_modsupport.h" // _PyArg_CheckPositional()
10
11 PyDoc_STRVAR(array_array_clear__doc__,
12 "clear($self, /)\n"
13 "--\n"
14 "\n"
15 "Remove all items from the array.");
16
17 #define ARRAY_ARRAY_CLEAR_METHODDEF \
18 {"clear", (PyCFunction)array_array_clear, METH_NOARGS, array_array_clear__doc__},
19
20 static PyObject *
21 array_array_clear_impl(arrayobject *self);
22
23 static PyObject *
array_array_clear(arrayobject * self,PyObject * Py_UNUSED (ignored))24 array_array_clear(arrayobject *self, PyObject *Py_UNUSED(ignored))
25 {
26 return array_array_clear_impl(self);
27 }
28
29 PyDoc_STRVAR(array_array___copy____doc__,
30 "__copy__($self, /)\n"
31 "--\n"
32 "\n"
33 "Return a copy of the array.");
34
35 #define ARRAY_ARRAY___COPY___METHODDEF \
36 {"__copy__", (PyCFunction)array_array___copy__, METH_NOARGS, array_array___copy____doc__},
37
38 static PyObject *
39 array_array___copy___impl(arrayobject *self);
40
41 static PyObject *
array_array___copy__(arrayobject * self,PyObject * Py_UNUSED (ignored))42 array_array___copy__(arrayobject *self, PyObject *Py_UNUSED(ignored))
43 {
44 return array_array___copy___impl(self);
45 }
46
47 PyDoc_STRVAR(array_array___deepcopy____doc__,
48 "__deepcopy__($self, unused, /)\n"
49 "--\n"
50 "\n"
51 "Return a copy of the array.");
52
53 #define ARRAY_ARRAY___DEEPCOPY___METHODDEF \
54 {"__deepcopy__", (PyCFunction)array_array___deepcopy__, METH_O, array_array___deepcopy____doc__},
55
56 PyDoc_STRVAR(array_array_count__doc__,
57 "count($self, v, /)\n"
58 "--\n"
59 "\n"
60 "Return number of occurrences of v in the array.");
61
62 #define ARRAY_ARRAY_COUNT_METHODDEF \
63 {"count", (PyCFunction)array_array_count, METH_O, array_array_count__doc__},
64
65 PyDoc_STRVAR(array_array_index__doc__,
66 "index($self, v, start=0, stop=sys.maxsize, /)\n"
67 "--\n"
68 "\n"
69 "Return index of first occurrence of v in the array.\n"
70 "\n"
71 "Raise ValueError if the value is not present.");
72
73 #define ARRAY_ARRAY_INDEX_METHODDEF \
74 {"index", _PyCFunction_CAST(array_array_index), METH_FASTCALL, array_array_index__doc__},
75
76 static PyObject *
77 array_array_index_impl(arrayobject *self, PyObject *v, Py_ssize_t start,
78 Py_ssize_t stop);
79
80 static PyObject *
array_array_index(arrayobject * self,PyObject * const * args,Py_ssize_t nargs)81 array_array_index(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
82 {
83 PyObject *return_value = NULL;
84 PyObject *v;
85 Py_ssize_t start = 0;
86 Py_ssize_t stop = PY_SSIZE_T_MAX;
87
88 if (!_PyArg_CheckPositional("index", nargs, 1, 3)) {
89 goto exit;
90 }
91 v = args[0];
92 if (nargs < 2) {
93 goto skip_optional;
94 }
95 if (!_PyEval_SliceIndexNotNone(args[1], &start)) {
96 goto exit;
97 }
98 if (nargs < 3) {
99 goto skip_optional;
100 }
101 if (!_PyEval_SliceIndexNotNone(args[2], &stop)) {
102 goto exit;
103 }
104 skip_optional:
105 return_value = array_array_index_impl(self, v, start, stop);
106
107 exit:
108 return return_value;
109 }
110
111 PyDoc_STRVAR(array_array_remove__doc__,
112 "remove($self, v, /)\n"
113 "--\n"
114 "\n"
115 "Remove the first occurrence of v in the array.");
116
117 #define ARRAY_ARRAY_REMOVE_METHODDEF \
118 {"remove", (PyCFunction)array_array_remove, METH_O, array_array_remove__doc__},
119
120 PyDoc_STRVAR(array_array_pop__doc__,
121 "pop($self, i=-1, /)\n"
122 "--\n"
123 "\n"
124 "Return the i-th element and delete it from the array.\n"
125 "\n"
126 "i defaults to -1.");
127
128 #define ARRAY_ARRAY_POP_METHODDEF \
129 {"pop", _PyCFunction_CAST(array_array_pop), METH_FASTCALL, array_array_pop__doc__},
130
131 static PyObject *
132 array_array_pop_impl(arrayobject *self, Py_ssize_t i);
133
134 static PyObject *
array_array_pop(arrayobject * self,PyObject * const * args,Py_ssize_t nargs)135 array_array_pop(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
136 {
137 PyObject *return_value = NULL;
138 Py_ssize_t i = -1;
139
140 if (!_PyArg_CheckPositional("pop", nargs, 0, 1)) {
141 goto exit;
142 }
143 if (nargs < 1) {
144 goto skip_optional;
145 }
146 {
147 Py_ssize_t ival = -1;
148 PyObject *iobj = _PyNumber_Index(args[0]);
149 if (iobj != NULL) {
150 ival = PyLong_AsSsize_t(iobj);
151 Py_DECREF(iobj);
152 }
153 if (ival == -1 && PyErr_Occurred()) {
154 goto exit;
155 }
156 i = ival;
157 }
158 skip_optional:
159 return_value = array_array_pop_impl(self, i);
160
161 exit:
162 return return_value;
163 }
164
165 PyDoc_STRVAR(array_array_extend__doc__,
166 "extend($self, bb, /)\n"
167 "--\n"
168 "\n"
169 "Append items to the end of the array.");
170
171 #define ARRAY_ARRAY_EXTEND_METHODDEF \
172 {"extend", _PyCFunction_CAST(array_array_extend), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array_extend__doc__},
173
174 static PyObject *
175 array_array_extend_impl(arrayobject *self, PyTypeObject *cls, PyObject *bb);
176
177 static PyObject *
array_array_extend(arrayobject * self,PyTypeObject * cls,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)178 array_array_extend(arrayobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
179 {
180 PyObject *return_value = NULL;
181 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
182 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
183 #else
184 # define KWTUPLE NULL
185 #endif
186
187 static const char * const _keywords[] = {"", NULL};
188 static _PyArg_Parser _parser = {
189 .keywords = _keywords,
190 .fname = "extend",
191 .kwtuple = KWTUPLE,
192 };
193 #undef KWTUPLE
194 PyObject *argsbuf[1];
195 PyObject *bb;
196
197 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
198 if (!args) {
199 goto exit;
200 }
201 bb = args[0];
202 return_value = array_array_extend_impl(self, cls, bb);
203
204 exit:
205 return return_value;
206 }
207
208 PyDoc_STRVAR(array_array_insert__doc__,
209 "insert($self, i, v, /)\n"
210 "--\n"
211 "\n"
212 "Insert a new item v into the array before position i.");
213
214 #define ARRAY_ARRAY_INSERT_METHODDEF \
215 {"insert", _PyCFunction_CAST(array_array_insert), METH_FASTCALL, array_array_insert__doc__},
216
217 static PyObject *
218 array_array_insert_impl(arrayobject *self, Py_ssize_t i, PyObject *v);
219
220 static PyObject *
array_array_insert(arrayobject * self,PyObject * const * args,Py_ssize_t nargs)221 array_array_insert(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
222 {
223 PyObject *return_value = NULL;
224 Py_ssize_t i;
225 PyObject *v;
226
227 if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
228 goto exit;
229 }
230 {
231 Py_ssize_t ival = -1;
232 PyObject *iobj = _PyNumber_Index(args[0]);
233 if (iobj != NULL) {
234 ival = PyLong_AsSsize_t(iobj);
235 Py_DECREF(iobj);
236 }
237 if (ival == -1 && PyErr_Occurred()) {
238 goto exit;
239 }
240 i = ival;
241 }
242 v = args[1];
243 return_value = array_array_insert_impl(self, i, v);
244
245 exit:
246 return return_value;
247 }
248
249 PyDoc_STRVAR(array_array_buffer_info__doc__,
250 "buffer_info($self, /)\n"
251 "--\n"
252 "\n"
253 "Return a tuple (address, length) giving the current memory address and the length in items of the buffer used to hold array\'s contents.\n"
254 "\n"
255 "The length should be multiplied by the itemsize attribute to calculate\n"
256 "the buffer length in bytes.");
257
258 #define ARRAY_ARRAY_BUFFER_INFO_METHODDEF \
259 {"buffer_info", (PyCFunction)array_array_buffer_info, METH_NOARGS, array_array_buffer_info__doc__},
260
261 static PyObject *
262 array_array_buffer_info_impl(arrayobject *self);
263
264 static PyObject *
array_array_buffer_info(arrayobject * self,PyObject * Py_UNUSED (ignored))265 array_array_buffer_info(arrayobject *self, PyObject *Py_UNUSED(ignored))
266 {
267 return array_array_buffer_info_impl(self);
268 }
269
270 PyDoc_STRVAR(array_array_append__doc__,
271 "append($self, v, /)\n"
272 "--\n"
273 "\n"
274 "Append new value v to the end of the array.");
275
276 #define ARRAY_ARRAY_APPEND_METHODDEF \
277 {"append", (PyCFunction)array_array_append, METH_O, array_array_append__doc__},
278
279 PyDoc_STRVAR(array_array_byteswap__doc__,
280 "byteswap($self, /)\n"
281 "--\n"
282 "\n"
283 "Byteswap all items of the array.\n"
284 "\n"
285 "If the items in the array are not 1, 2, 4, or 8 bytes in size, RuntimeError is\n"
286 "raised.");
287
288 #define ARRAY_ARRAY_BYTESWAP_METHODDEF \
289 {"byteswap", (PyCFunction)array_array_byteswap, METH_NOARGS, array_array_byteswap__doc__},
290
291 static PyObject *
292 array_array_byteswap_impl(arrayobject *self);
293
294 static PyObject *
array_array_byteswap(arrayobject * self,PyObject * Py_UNUSED (ignored))295 array_array_byteswap(arrayobject *self, PyObject *Py_UNUSED(ignored))
296 {
297 return array_array_byteswap_impl(self);
298 }
299
300 PyDoc_STRVAR(array_array_reverse__doc__,
301 "reverse($self, /)\n"
302 "--\n"
303 "\n"
304 "Reverse the order of the items in the array.");
305
306 #define ARRAY_ARRAY_REVERSE_METHODDEF \
307 {"reverse", (PyCFunction)array_array_reverse, METH_NOARGS, array_array_reverse__doc__},
308
309 static PyObject *
310 array_array_reverse_impl(arrayobject *self);
311
312 static PyObject *
array_array_reverse(arrayobject * self,PyObject * Py_UNUSED (ignored))313 array_array_reverse(arrayobject *self, PyObject *Py_UNUSED(ignored))
314 {
315 return array_array_reverse_impl(self);
316 }
317
318 PyDoc_STRVAR(array_array_fromfile__doc__,
319 "fromfile($self, f, n, /)\n"
320 "--\n"
321 "\n"
322 "Read n objects from the file object f and append them to the end of the array.");
323
324 #define ARRAY_ARRAY_FROMFILE_METHODDEF \
325 {"fromfile", _PyCFunction_CAST(array_array_fromfile), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array_fromfile__doc__},
326
327 static PyObject *
328 array_array_fromfile_impl(arrayobject *self, PyTypeObject *cls, PyObject *f,
329 Py_ssize_t n);
330
331 static PyObject *
array_array_fromfile(arrayobject * self,PyTypeObject * cls,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)332 array_array_fromfile(arrayobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
333 {
334 PyObject *return_value = NULL;
335 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
336 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
337 #else
338 # define KWTUPLE NULL
339 #endif
340
341 static const char * const _keywords[] = {"", "", NULL};
342 static _PyArg_Parser _parser = {
343 .keywords = _keywords,
344 .fname = "fromfile",
345 .kwtuple = KWTUPLE,
346 };
347 #undef KWTUPLE
348 PyObject *argsbuf[2];
349 PyObject *f;
350 Py_ssize_t n;
351
352 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
353 if (!args) {
354 goto exit;
355 }
356 f = args[0];
357 {
358 Py_ssize_t ival = -1;
359 PyObject *iobj = _PyNumber_Index(args[1]);
360 if (iobj != NULL) {
361 ival = PyLong_AsSsize_t(iobj);
362 Py_DECREF(iobj);
363 }
364 if (ival == -1 && PyErr_Occurred()) {
365 goto exit;
366 }
367 n = ival;
368 }
369 return_value = array_array_fromfile_impl(self, cls, f, n);
370
371 exit:
372 return return_value;
373 }
374
375 PyDoc_STRVAR(array_array_tofile__doc__,
376 "tofile($self, f, /)\n"
377 "--\n"
378 "\n"
379 "Write all items (as machine values) to the file object f.");
380
381 #define ARRAY_ARRAY_TOFILE_METHODDEF \
382 {"tofile", _PyCFunction_CAST(array_array_tofile), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array_tofile__doc__},
383
384 static PyObject *
385 array_array_tofile_impl(arrayobject *self, PyTypeObject *cls, PyObject *f);
386
387 static PyObject *
array_array_tofile(arrayobject * self,PyTypeObject * cls,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)388 array_array_tofile(arrayobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
389 {
390 PyObject *return_value = NULL;
391 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
392 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
393 #else
394 # define KWTUPLE NULL
395 #endif
396
397 static const char * const _keywords[] = {"", NULL};
398 static _PyArg_Parser _parser = {
399 .keywords = _keywords,
400 .fname = "tofile",
401 .kwtuple = KWTUPLE,
402 };
403 #undef KWTUPLE
404 PyObject *argsbuf[1];
405 PyObject *f;
406
407 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
408 if (!args) {
409 goto exit;
410 }
411 f = args[0];
412 return_value = array_array_tofile_impl(self, cls, f);
413
414 exit:
415 return return_value;
416 }
417
418 PyDoc_STRVAR(array_array_fromlist__doc__,
419 "fromlist($self, list, /)\n"
420 "--\n"
421 "\n"
422 "Append items to array from list.");
423
424 #define ARRAY_ARRAY_FROMLIST_METHODDEF \
425 {"fromlist", (PyCFunction)array_array_fromlist, METH_O, array_array_fromlist__doc__},
426
427 PyDoc_STRVAR(array_array_tolist__doc__,
428 "tolist($self, /)\n"
429 "--\n"
430 "\n"
431 "Convert array to an ordinary list with the same items.");
432
433 #define ARRAY_ARRAY_TOLIST_METHODDEF \
434 {"tolist", (PyCFunction)array_array_tolist, METH_NOARGS, array_array_tolist__doc__},
435
436 static PyObject *
437 array_array_tolist_impl(arrayobject *self);
438
439 static PyObject *
array_array_tolist(arrayobject * self,PyObject * Py_UNUSED (ignored))440 array_array_tolist(arrayobject *self, PyObject *Py_UNUSED(ignored))
441 {
442 return array_array_tolist_impl(self);
443 }
444
445 PyDoc_STRVAR(array_array_frombytes__doc__,
446 "frombytes($self, buffer, /)\n"
447 "--\n"
448 "\n"
449 "Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method.");
450
451 #define ARRAY_ARRAY_FROMBYTES_METHODDEF \
452 {"frombytes", (PyCFunction)array_array_frombytes, METH_O, array_array_frombytes__doc__},
453
454 static PyObject *
455 array_array_frombytes_impl(arrayobject *self, Py_buffer *buffer);
456
457 static PyObject *
array_array_frombytes(arrayobject * self,PyObject * arg)458 array_array_frombytes(arrayobject *self, PyObject *arg)
459 {
460 PyObject *return_value = NULL;
461 Py_buffer buffer = {NULL, NULL};
462
463 if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
464 goto exit;
465 }
466 return_value = array_array_frombytes_impl(self, &buffer);
467
468 exit:
469 /* Cleanup for buffer */
470 if (buffer.obj) {
471 PyBuffer_Release(&buffer);
472 }
473
474 return return_value;
475 }
476
477 PyDoc_STRVAR(array_array_tobytes__doc__,
478 "tobytes($self, /)\n"
479 "--\n"
480 "\n"
481 "Convert the array to an array of machine values and return the bytes representation.");
482
483 #define ARRAY_ARRAY_TOBYTES_METHODDEF \
484 {"tobytes", (PyCFunction)array_array_tobytes, METH_NOARGS, array_array_tobytes__doc__},
485
486 static PyObject *
487 array_array_tobytes_impl(arrayobject *self);
488
489 static PyObject *
array_array_tobytes(arrayobject * self,PyObject * Py_UNUSED (ignored))490 array_array_tobytes(arrayobject *self, PyObject *Py_UNUSED(ignored))
491 {
492 return array_array_tobytes_impl(self);
493 }
494
495 PyDoc_STRVAR(array_array_fromunicode__doc__,
496 "fromunicode($self, ustr, /)\n"
497 "--\n"
498 "\n"
499 "Extends this array with data from the unicode string ustr.\n"
500 "\n"
501 "The array must be a unicode type array; otherwise a ValueError is raised.\n"
502 "Use array.frombytes(ustr.encode(...)) to append Unicode data to an array of\n"
503 "some other type.");
504
505 #define ARRAY_ARRAY_FROMUNICODE_METHODDEF \
506 {"fromunicode", (PyCFunction)array_array_fromunicode, METH_O, array_array_fromunicode__doc__},
507
508 static PyObject *
509 array_array_fromunicode_impl(arrayobject *self, PyObject *ustr);
510
511 static PyObject *
array_array_fromunicode(arrayobject * self,PyObject * arg)512 array_array_fromunicode(arrayobject *self, PyObject *arg)
513 {
514 PyObject *return_value = NULL;
515 PyObject *ustr;
516
517 if (!PyUnicode_Check(arg)) {
518 _PyArg_BadArgument("fromunicode", "argument", "str", arg);
519 goto exit;
520 }
521 ustr = arg;
522 return_value = array_array_fromunicode_impl(self, ustr);
523
524 exit:
525 return return_value;
526 }
527
528 PyDoc_STRVAR(array_array_tounicode__doc__,
529 "tounicode($self, /)\n"
530 "--\n"
531 "\n"
532 "Extends this array with data from the unicode string ustr.\n"
533 "\n"
534 "Convert the array to a unicode string. The array must be a unicode type array;\n"
535 "otherwise a ValueError is raised. Use array.tobytes().decode() to obtain a\n"
536 "unicode string from an array of some other type.");
537
538 #define ARRAY_ARRAY_TOUNICODE_METHODDEF \
539 {"tounicode", (PyCFunction)array_array_tounicode, METH_NOARGS, array_array_tounicode__doc__},
540
541 static PyObject *
542 array_array_tounicode_impl(arrayobject *self);
543
544 static PyObject *
array_array_tounicode(arrayobject * self,PyObject * Py_UNUSED (ignored))545 array_array_tounicode(arrayobject *self, PyObject *Py_UNUSED(ignored))
546 {
547 return array_array_tounicode_impl(self);
548 }
549
550 PyDoc_STRVAR(array_array___sizeof____doc__,
551 "__sizeof__($self, /)\n"
552 "--\n"
553 "\n"
554 "Size of the array in memory, in bytes.");
555
556 #define ARRAY_ARRAY___SIZEOF___METHODDEF \
557 {"__sizeof__", (PyCFunction)array_array___sizeof__, METH_NOARGS, array_array___sizeof____doc__},
558
559 static PyObject *
560 array_array___sizeof___impl(arrayobject *self);
561
562 static PyObject *
array_array___sizeof__(arrayobject * self,PyObject * Py_UNUSED (ignored))563 array_array___sizeof__(arrayobject *self, PyObject *Py_UNUSED(ignored))
564 {
565 return array_array___sizeof___impl(self);
566 }
567
568 PyDoc_STRVAR(array__array_reconstructor__doc__,
569 "_array_reconstructor($module, arraytype, typecode, mformat_code, items,\n"
570 " /)\n"
571 "--\n"
572 "\n"
573 "Internal. Used for pickling support.");
574
575 #define ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF \
576 {"_array_reconstructor", _PyCFunction_CAST(array__array_reconstructor), METH_FASTCALL, array__array_reconstructor__doc__},
577
578 static PyObject *
579 array__array_reconstructor_impl(PyObject *module, PyTypeObject *arraytype,
580 int typecode,
581 enum machine_format_code mformat_code,
582 PyObject *items);
583
584 static PyObject *
array__array_reconstructor(PyObject * module,PyObject * const * args,Py_ssize_t nargs)585 array__array_reconstructor(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
586 {
587 PyObject *return_value = NULL;
588 PyTypeObject *arraytype;
589 int typecode;
590 enum machine_format_code mformat_code;
591 PyObject *items;
592
593 if (!_PyArg_CheckPositional("_array_reconstructor", nargs, 4, 4)) {
594 goto exit;
595 }
596 arraytype = (PyTypeObject *)args[0];
597 if (!PyUnicode_Check(args[1])) {
598 _PyArg_BadArgument("_array_reconstructor", "argument 2", "a unicode character", args[1]);
599 goto exit;
600 }
601 if (PyUnicode_GET_LENGTH(args[1]) != 1) {
602 _PyArg_BadArgument("_array_reconstructor", "argument 2", "a unicode character", args[1]);
603 goto exit;
604 }
605 typecode = PyUnicode_READ_CHAR(args[1], 0);
606 mformat_code = PyLong_AsInt(args[2]);
607 if (mformat_code == -1 && PyErr_Occurred()) {
608 goto exit;
609 }
610 items = args[3];
611 return_value = array__array_reconstructor_impl(module, arraytype, typecode, mformat_code, items);
612
613 exit:
614 return return_value;
615 }
616
617 PyDoc_STRVAR(array_array___reduce_ex____doc__,
618 "__reduce_ex__($self, value, /)\n"
619 "--\n"
620 "\n"
621 "Return state information for pickling.");
622
623 #define ARRAY_ARRAY___REDUCE_EX___METHODDEF \
624 {"__reduce_ex__", _PyCFunction_CAST(array_array___reduce_ex__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array___reduce_ex____doc__},
625
626 static PyObject *
627 array_array___reduce_ex___impl(arrayobject *self, PyTypeObject *cls,
628 PyObject *value);
629
630 static PyObject *
array_array___reduce_ex__(arrayobject * self,PyTypeObject * cls,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)631 array_array___reduce_ex__(arrayobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
632 {
633 PyObject *return_value = NULL;
634 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
635 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
636 #else
637 # define KWTUPLE NULL
638 #endif
639
640 static const char * const _keywords[] = {"", NULL};
641 static _PyArg_Parser _parser = {
642 .keywords = _keywords,
643 .fname = "__reduce_ex__",
644 .kwtuple = KWTUPLE,
645 };
646 #undef KWTUPLE
647 PyObject *argsbuf[1];
648 PyObject *value;
649
650 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
651 if (!args) {
652 goto exit;
653 }
654 value = args[0];
655 return_value = array_array___reduce_ex___impl(self, cls, value);
656
657 exit:
658 return return_value;
659 }
660
661 PyDoc_STRVAR(array_arrayiterator___reduce____doc__,
662 "__reduce__($self, /)\n"
663 "--\n"
664 "\n"
665 "Return state information for pickling.");
666
667 #define ARRAY_ARRAYITERATOR___REDUCE___METHODDEF \
668 {"__reduce__", _PyCFunction_CAST(array_arrayiterator___reduce__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_arrayiterator___reduce____doc__},
669
670 static PyObject *
671 array_arrayiterator___reduce___impl(arrayiterobject *self, PyTypeObject *cls);
672
673 static PyObject *
array_arrayiterator___reduce__(arrayiterobject * self,PyTypeObject * cls,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)674 array_arrayiterator___reduce__(arrayiterobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
675 {
676 if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
677 PyErr_SetString(PyExc_TypeError, "__reduce__() takes no arguments");
678 return NULL;
679 }
680 return array_arrayiterator___reduce___impl(self, cls);
681 }
682
683 PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
684 "__setstate__($self, state, /)\n"
685 "--\n"
686 "\n"
687 "Set state information for unpickling.");
688
689 #define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
690 {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
691 /*[clinic end generated code: output=f675e0d433ae34b6 input=a9049054013a1b77]*/
692