Debian Codegraph @

Modules/clinic/arraymodule.c.h

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