1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #include "pycore_abstract.h" // _PyNumber_Index()
6 #include "pycore_modsupport.h" // _PyArg_CheckPositional()
7
8 PyDoc_STRVAR(_operator_truth__doc__,
9 "truth($module, a, /)\n"
10 "--\n"
11 "\n"
12 "Return True if a is true, False otherwise.");
13
14 #define _OPERATOR_TRUTH_METHODDEF \
15 {"truth", (PyCFunction)_operator_truth, METH_O, _operator_truth__doc__},
16
17 static int
18 _operator_truth_impl(PyObject *module, PyObject *a);
19
20 static PyObject *
_operator_truth(PyObject * module,PyObject * a)21 _operator_truth(PyObject *module, PyObject *a)
22 {
23 PyObject *return_value = NULL;
24 int _return_value;
25
26 _return_value = _operator_truth_impl(module, a);
27 if ((_return_value == -1) && PyErr_Occurred()) {
28 goto exit;
29 }
30 return_value = PyBool_FromLong((long)_return_value);
31
32 exit:
33 return return_value;
34 }
35
36 PyDoc_STRVAR(_operator_add__doc__,
37 "add($module, a, b, /)\n"
38 "--\n"
39 "\n"
40 "Same as a + b.");
41
42 #define _OPERATOR_ADD_METHODDEF \
43 {"add", _PyCFunction_CAST(_operator_add), METH_FASTCALL, _operator_add__doc__},
44
45 static PyObject *
46 _operator_add_impl(PyObject *module, PyObject *a, PyObject *b);
47
48 static PyObject *
_operator_add(PyObject * module,PyObject * const * args,Py_ssize_t nargs)49 _operator_add(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
50 {
51 PyObject *return_value = NULL;
52 PyObject *a;
53 PyObject *b;
54
55 if (!_PyArg_CheckPositional("add", nargs, 2, 2)) {
56 goto exit;
57 }
58 a = args[0];
59 b = args[1];
60 return_value = _operator_add_impl(module, a, b);
61
62 exit:
63 return return_value;
64 }
65
66 PyDoc_STRVAR(_operator_sub__doc__,
67 "sub($module, a, b, /)\n"
68 "--\n"
69 "\n"
70 "Same as a - b.");
71
72 #define _OPERATOR_SUB_METHODDEF \
73 {"sub", _PyCFunction_CAST(_operator_sub), METH_FASTCALL, _operator_sub__doc__},
74
75 static PyObject *
76 _operator_sub_impl(PyObject *module, PyObject *a, PyObject *b);
77
78 static PyObject *
_operator_sub(PyObject * module,PyObject * const * args,Py_ssize_t nargs)79 _operator_sub(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
80 {
81 PyObject *return_value = NULL;
82 PyObject *a;
83 PyObject *b;
84
85 if (!_PyArg_CheckPositional("sub", nargs, 2, 2)) {
86 goto exit;
87 }
88 a = args[0];
89 b = args[1];
90 return_value = _operator_sub_impl(module, a, b);
91
92 exit:
93 return return_value;
94 }
95
96 PyDoc_STRVAR(_operator_mul__doc__,
97 "mul($module, a, b, /)\n"
98 "--\n"
99 "\n"
100 "Same as a * b.");
101
102 #define _OPERATOR_MUL_METHODDEF \
103 {"mul", _PyCFunction_CAST(_operator_mul), METH_FASTCALL, _operator_mul__doc__},
104
105 static PyObject *
106 _operator_mul_impl(PyObject *module, PyObject *a, PyObject *b);
107
108 static PyObject *
_operator_mul(PyObject * module,PyObject * const * args,Py_ssize_t nargs)109 _operator_mul(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
110 {
111 PyObject *return_value = NULL;
112 PyObject *a;
113 PyObject *b;
114
115 if (!_PyArg_CheckPositional("mul", nargs, 2, 2)) {
116 goto exit;
117 }
118 a = args[0];
119 b = args[1];
120 return_value = _operator_mul_impl(module, a, b);
121
122 exit:
123 return return_value;
124 }
125
126 PyDoc_STRVAR(_operator_matmul__doc__,
127 "matmul($module, a, b, /)\n"
128 "--\n"
129 "\n"
130 "Same as a @ b.");
131
132 #define _OPERATOR_MATMUL_METHODDEF \
133 {"matmul", _PyCFunction_CAST(_operator_matmul), METH_FASTCALL, _operator_matmul__doc__},
134
135 static PyObject *
136 _operator_matmul_impl(PyObject *module, PyObject *a, PyObject *b);
137
138 static PyObject *
_operator_matmul(PyObject * module,PyObject * const * args,Py_ssize_t nargs)139 _operator_matmul(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
140 {
141 PyObject *return_value = NULL;
142 PyObject *a;
143 PyObject *b;
144
145 if (!_PyArg_CheckPositional("matmul", nargs, 2, 2)) {
146 goto exit;
147 }
148 a = args[0];
149 b = args[1];
150 return_value = _operator_matmul_impl(module, a, b);
151
152 exit:
153 return return_value;
154 }
155
156 PyDoc_STRVAR(_operator_floordiv__doc__,
157 "floordiv($module, a, b, /)\n"
158 "--\n"
159 "\n"
160 "Same as a // b.");
161
162 #define _OPERATOR_FLOORDIV_METHODDEF \
163 {"floordiv", _PyCFunction_CAST(_operator_floordiv), METH_FASTCALL, _operator_floordiv__doc__},
164
165 static PyObject *
166 _operator_floordiv_impl(PyObject *module, PyObject *a, PyObject *b);
167
168 static PyObject *
_operator_floordiv(PyObject * module,PyObject * const * args,Py_ssize_t nargs)169 _operator_floordiv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
170 {
171 PyObject *return_value = NULL;
172 PyObject *a;
173 PyObject *b;
174
175 if (!_PyArg_CheckPositional("floordiv", nargs, 2, 2)) {
176 goto exit;
177 }
178 a = args[0];
179 b = args[1];
180 return_value = _operator_floordiv_impl(module, a, b);
181
182 exit:
183 return return_value;
184 }
185
186 PyDoc_STRVAR(_operator_truediv__doc__,
187 "truediv($module, a, b, /)\n"
188 "--\n"
189 "\n"
190 "Same as a / b.");
191
192 #define _OPERATOR_TRUEDIV_METHODDEF \
193 {"truediv", _PyCFunction_CAST(_operator_truediv), METH_FASTCALL, _operator_truediv__doc__},
194
195 static PyObject *
196 _operator_truediv_impl(PyObject *module, PyObject *a, PyObject *b);
197
198 static PyObject *
_operator_truediv(PyObject * module,PyObject * const * args,Py_ssize_t nargs)199 _operator_truediv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
200 {
201 PyObject *return_value = NULL;
202 PyObject *a;
203 PyObject *b;
204
205 if (!_PyArg_CheckPositional("truediv", nargs, 2, 2)) {
206 goto exit;
207 }
208 a = args[0];
209 b = args[1];
210 return_value = _operator_truediv_impl(module, a, b);
211
212 exit:
213 return return_value;
214 }
215
216 PyDoc_STRVAR(_operator_mod__doc__,
217 "mod($module, a, b, /)\n"
218 "--\n"
219 "\n"
220 "Same as a % b.");
221
222 #define _OPERATOR_MOD_METHODDEF \
223 {"mod", _PyCFunction_CAST(_operator_mod), METH_FASTCALL, _operator_mod__doc__},
224
225 static PyObject *
226 _operator_mod_impl(PyObject *module, PyObject *a, PyObject *b);
227
228 static PyObject *
_operator_mod(PyObject * module,PyObject * const * args,Py_ssize_t nargs)229 _operator_mod(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
230 {
231 PyObject *return_value = NULL;
232 PyObject *a;
233 PyObject *b;
234
235 if (!_PyArg_CheckPositional("mod", nargs, 2, 2)) {
236 goto exit;
237 }
238 a = args[0];
239 b = args[1];
240 return_value = _operator_mod_impl(module, a, b);
241
242 exit:
243 return return_value;
244 }
245
246 PyDoc_STRVAR(_operator_neg__doc__,
247 "neg($module, a, /)\n"
248 "--\n"
249 "\n"
250 "Same as -a.");
251
252 #define _OPERATOR_NEG_METHODDEF \
253 {"neg", (PyCFunction)_operator_neg, METH_O, _operator_neg__doc__},
254
255 PyDoc_STRVAR(_operator_pos__doc__,
256 "pos($module, a, /)\n"
257 "--\n"
258 "\n"
259 "Same as +a.");
260
261 #define _OPERATOR_POS_METHODDEF \
262 {"pos", (PyCFunction)_operator_pos, METH_O, _operator_pos__doc__},
263
264 PyDoc_STRVAR(_operator_abs__doc__,
265 "abs($module, a, /)\n"
266 "--\n"
267 "\n"
268 "Same as abs(a).");
269
270 #define _OPERATOR_ABS_METHODDEF \
271 {"abs", (PyCFunction)_operator_abs, METH_O, _operator_abs__doc__},
272
273 PyDoc_STRVAR(_operator_inv__doc__,
274 "inv($module, a, /)\n"
275 "--\n"
276 "\n"
277 "Same as ~a.");
278
279 #define _OPERATOR_INV_METHODDEF \
280 {"inv", (PyCFunction)_operator_inv, METH_O, _operator_inv__doc__},
281
282 PyDoc_STRVAR(_operator_invert__doc__,
283 "invert($module, a, /)\n"
284 "--\n"
285 "\n"
286 "Same as ~a.");
287
288 #define _OPERATOR_INVERT_METHODDEF \
289 {"invert", (PyCFunction)_operator_invert, METH_O, _operator_invert__doc__},
290
291 PyDoc_STRVAR(_operator_lshift__doc__,
292 "lshift($module, a, b, /)\n"
293 "--\n"
294 "\n"
295 "Same as a << b.");
296
297 #define _OPERATOR_LSHIFT_METHODDEF \
298 {"lshift", _PyCFunction_CAST(_operator_lshift), METH_FASTCALL, _operator_lshift__doc__},
299
300 static PyObject *
301 _operator_lshift_impl(PyObject *module, PyObject *a, PyObject *b);
302
303 static PyObject *
_operator_lshift(PyObject * module,PyObject * const * args,Py_ssize_t nargs)304 _operator_lshift(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
305 {
306 PyObject *return_value = NULL;
307 PyObject *a;
308 PyObject *b;
309
310 if (!_PyArg_CheckPositional("lshift", nargs, 2, 2)) {
311 goto exit;
312 }
313 a = args[0];
314 b = args[1];
315 return_value = _operator_lshift_impl(module, a, b);
316
317 exit:
318 return return_value;
319 }
320
321 PyDoc_STRVAR(_operator_rshift__doc__,
322 "rshift($module, a, b, /)\n"
323 "--\n"
324 "\n"
325 "Same as a >> b.");
326
327 #define _OPERATOR_RSHIFT_METHODDEF \
328 {"rshift", _PyCFunction_CAST(_operator_rshift), METH_FASTCALL, _operator_rshift__doc__},
329
330 static PyObject *
331 _operator_rshift_impl(PyObject *module, PyObject *a, PyObject *b);
332
333 static PyObject *
_operator_rshift(PyObject * module,PyObject * const * args,Py_ssize_t nargs)334 _operator_rshift(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
335 {
336 PyObject *return_value = NULL;
337 PyObject *a;
338 PyObject *b;
339
340 if (!_PyArg_CheckPositional("rshift", nargs, 2, 2)) {
341 goto exit;
342 }
343 a = args[0];
344 b = args[1];
345 return_value = _operator_rshift_impl(module, a, b);
346
347 exit:
348 return return_value;
349 }
350
351 PyDoc_STRVAR(_operator_not___doc__,
352 "not_($module, a, /)\n"
353 "--\n"
354 "\n"
355 "Same as not a.");
356
357 #define _OPERATOR_NOT__METHODDEF \
358 {"not_", (PyCFunction)_operator_not_, METH_O, _operator_not___doc__},
359
360 static int
361 _operator_not__impl(PyObject *module, PyObject *a);
362
363 static PyObject *
_operator_not_(PyObject * module,PyObject * a)364 _operator_not_(PyObject *module, PyObject *a)
365 {
366 PyObject *return_value = NULL;
367 int _return_value;
368
369 _return_value = _operator_not__impl(module, a);
370 if ((_return_value == -1) && PyErr_Occurred()) {
371 goto exit;
372 }
373 return_value = PyBool_FromLong((long)_return_value);
374
375 exit:
376 return return_value;
377 }
378
379 PyDoc_STRVAR(_operator_and___doc__,
380 "and_($module, a, b, /)\n"
381 "--\n"
382 "\n"
383 "Same as a & b.");
384
385 #define _OPERATOR_AND__METHODDEF \
386 {"and_", _PyCFunction_CAST(_operator_and_), METH_FASTCALL, _operator_and___doc__},
387
388 static PyObject *
389 _operator_and__impl(PyObject *module, PyObject *a, PyObject *b);
390
391 static PyObject *
_operator_and_(PyObject * module,PyObject * const * args,Py_ssize_t nargs)392 _operator_and_(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
393 {
394 PyObject *return_value = NULL;
395 PyObject *a;
396 PyObject *b;
397
398 if (!_PyArg_CheckPositional("and_", nargs, 2, 2)) {
399 goto exit;
400 }
401 a = args[0];
402 b = args[1];
403 return_value = _operator_and__impl(module, a, b);
404
405 exit:
406 return return_value;
407 }
408
409 PyDoc_STRVAR(_operator_xor__doc__,
410 "xor($module, a, b, /)\n"
411 "--\n"
412 "\n"
413 "Same as a ^ b.");
414
415 #define _OPERATOR_XOR_METHODDEF \
416 {"xor", _PyCFunction_CAST(_operator_xor), METH_FASTCALL, _operator_xor__doc__},
417
418 static PyObject *
419 _operator_xor_impl(PyObject *module, PyObject *a, PyObject *b);
420
421 static PyObject *
_operator_xor(PyObject * module,PyObject * const * args,Py_ssize_t nargs)422 _operator_xor(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
423 {
424 PyObject *return_value = NULL;
425 PyObject *a;
426 PyObject *b;
427
428 if (!_PyArg_CheckPositional("xor", nargs, 2, 2)) {
429 goto exit;
430 }
431 a = args[0];
432 b = args[1];
433 return_value = _operator_xor_impl(module, a, b);
434
435 exit:
436 return return_value;
437 }
438
439 PyDoc_STRVAR(_operator_or___doc__,
440 "or_($module, a, b, /)\n"
441 "--\n"
442 "\n"
443 "Same as a | b.");
444
445 #define _OPERATOR_OR__METHODDEF \
446 {"or_", _PyCFunction_CAST(_operator_or_), METH_FASTCALL, _operator_or___doc__},
447
448 static PyObject *
449 _operator_or__impl(PyObject *module, PyObject *a, PyObject *b);
450
451 static PyObject *
_operator_or_(PyObject * module,PyObject * const * args,Py_ssize_t nargs)452 _operator_or_(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
453 {
454 PyObject *return_value = NULL;
455 PyObject *a;
456 PyObject *b;
457
458 if (!_PyArg_CheckPositional("or_", nargs, 2, 2)) {
459 goto exit;
460 }
461 a = args[0];
462 b = args[1];
463 return_value = _operator_or__impl(module, a, b);
464
465 exit:
466 return return_value;
467 }
468
469 PyDoc_STRVAR(_operator_iadd__doc__,
470 "iadd($module, a, b, /)\n"
471 "--\n"
472 "\n"
473 "Same as a += b.");
474
475 #define _OPERATOR_IADD_METHODDEF \
476 {"iadd", _PyCFunction_CAST(_operator_iadd), METH_FASTCALL, _operator_iadd__doc__},
477
478 static PyObject *
479 _operator_iadd_impl(PyObject *module, PyObject *a, PyObject *b);
480
481 static PyObject *
_operator_iadd(PyObject * module,PyObject * const * args,Py_ssize_t nargs)482 _operator_iadd(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
483 {
484 PyObject *return_value = NULL;
485 PyObject *a;
486 PyObject *b;
487
488 if (!_PyArg_CheckPositional("iadd", nargs, 2, 2)) {
489 goto exit;
490 }
491 a = args[0];
492 b = args[1];
493 return_value = _operator_iadd_impl(module, a, b);
494
495 exit:
496 return return_value;
497 }
498
499 PyDoc_STRVAR(_operator_isub__doc__,
500 "isub($module, a, b, /)\n"
501 "--\n"
502 "\n"
503 "Same as a -= b.");
504
505 #define _OPERATOR_ISUB_METHODDEF \
506 {"isub", _PyCFunction_CAST(_operator_isub), METH_FASTCALL, _operator_isub__doc__},
507
508 static PyObject *
509 _operator_isub_impl(PyObject *module, PyObject *a, PyObject *b);
510
511 static PyObject *
_operator_isub(PyObject * module,PyObject * const * args,Py_ssize_t nargs)512 _operator_isub(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
513 {
514 PyObject *return_value = NULL;
515 PyObject *a;
516 PyObject *b;
517
518 if (!_PyArg_CheckPositional("isub", nargs, 2, 2)) {
519 goto exit;
520 }
521 a = args[0];
522 b = args[1];
523 return_value = _operator_isub_impl(module, a, b);
524
525 exit:
526 return return_value;
527 }
528
529 PyDoc_STRVAR(_operator_imul__doc__,
530 "imul($module, a, b, /)\n"
531 "--\n"
532 "\n"
533 "Same as a *= b.");
534
535 #define _OPERATOR_IMUL_METHODDEF \
536 {"imul", _PyCFunction_CAST(_operator_imul), METH_FASTCALL, _operator_imul__doc__},
537
538 static PyObject *
539 _operator_imul_impl(PyObject *module, PyObject *a, PyObject *b);
540
541 static PyObject *
_operator_imul(PyObject * module,PyObject * const * args,Py_ssize_t nargs)542 _operator_imul(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
543 {
544 PyObject *return_value = NULL;
545 PyObject *a;
546 PyObject *b;
547
548 if (!_PyArg_CheckPositional("imul", nargs, 2, 2)) {
549 goto exit;
550 }
551 a = args[0];
552 b = args[1];
553 return_value = _operator_imul_impl(module, a, b);
554
555 exit:
556 return return_value;
557 }
558
559 PyDoc_STRVAR(_operator_imatmul__doc__,
560 "imatmul($module, a, b, /)\n"
561 "--\n"
562 "\n"
563 "Same as a @= b.");
564
565 #define _OPERATOR_IMATMUL_METHODDEF \
566 {"imatmul", _PyCFunction_CAST(_operator_imatmul), METH_FASTCALL, _operator_imatmul__doc__},
567
568 static PyObject *
569 _operator_imatmul_impl(PyObject *module, PyObject *a, PyObject *b);
570
571 static PyObject *
_operator_imatmul(PyObject * module,PyObject * const * args,Py_ssize_t nargs)572 _operator_imatmul(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
573 {
574 PyObject *return_value = NULL;
575 PyObject *a;
576 PyObject *b;
577
578 if (!_PyArg_CheckPositional("imatmul", nargs, 2, 2)) {
579 goto exit;
580 }
581 a = args[0];
582 b = args[1];
583 return_value = _operator_imatmul_impl(module, a, b);
584
585 exit:
586 return return_value;
587 }
588
589 PyDoc_STRVAR(_operator_ifloordiv__doc__,
590 "ifloordiv($module, a, b, /)\n"
591 "--\n"
592 "\n"
593 "Same as a //= b.");
594
595 #define _OPERATOR_IFLOORDIV_METHODDEF \
596 {"ifloordiv", _PyCFunction_CAST(_operator_ifloordiv), METH_FASTCALL, _operator_ifloordiv__doc__},
597
598 static PyObject *
599 _operator_ifloordiv_impl(PyObject *module, PyObject *a, PyObject *b);
600
601 static PyObject *
_operator_ifloordiv(PyObject * module,PyObject * const * args,Py_ssize_t nargs)602 _operator_ifloordiv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
603 {
604 PyObject *return_value = NULL;
605 PyObject *a;
606 PyObject *b;
607
608 if (!_PyArg_CheckPositional("ifloordiv", nargs, 2, 2)) {
609 goto exit;
610 }
611 a = args[0];
612 b = args[1];
613 return_value = _operator_ifloordiv_impl(module, a, b);
614
615 exit:
616 return return_value;
617 }
618
619 PyDoc_STRVAR(_operator_itruediv__doc__,
620 "itruediv($module, a, b, /)\n"
621 "--\n"
622 "\n"
623 "Same as a /= b.");
624
625 #define _OPERATOR_ITRUEDIV_METHODDEF \
626 {"itruediv", _PyCFunction_CAST(_operator_itruediv), METH_FASTCALL, _operator_itruediv__doc__},
627
628 static PyObject *
629 _operator_itruediv_impl(PyObject *module, PyObject *a, PyObject *b);
630
631 static PyObject *
_operator_itruediv(PyObject * module,PyObject * const * args,Py_ssize_t nargs)632 _operator_itruediv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
633 {
634 PyObject *return_value = NULL;
635 PyObject *a;
636 PyObject *b;
637
638 if (!_PyArg_CheckPositional("itruediv", nargs, 2, 2)) {
639 goto exit;
640 }
641 a = args[0];
642 b = args[1];
643 return_value = _operator_itruediv_impl(module, a, b);
644
645 exit:
646 return return_value;
647 }
648
649 PyDoc_STRVAR(_operator_imod__doc__,
650 "imod($module, a, b, /)\n"
651 "--\n"
652 "\n"
653 "Same as a %= b.");
654
655 #define _OPERATOR_IMOD_METHODDEF \
656 {"imod", _PyCFunction_CAST(_operator_imod), METH_FASTCALL, _operator_imod__doc__},
657
658 static PyObject *
659 _operator_imod_impl(PyObject *module, PyObject *a, PyObject *b);
660
661 static PyObject *
_operator_imod(PyObject * module,PyObject * const * args,Py_ssize_t nargs)662 _operator_imod(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
663 {
664 PyObject *return_value = NULL;
665 PyObject *a;
666 PyObject *b;
667
668 if (!_PyArg_CheckPositional("imod", nargs, 2, 2)) {
669 goto exit;
670 }
671 a = args[0];
672 b = args[1];
673 return_value = _operator_imod_impl(module, a, b);
674
675 exit:
676 return return_value;
677 }
678
679 PyDoc_STRVAR(_operator_ilshift__doc__,
680 "ilshift($module, a, b, /)\n"
681 "--\n"
682 "\n"
683 "Same as a <<= b.");
684
685 #define _OPERATOR_ILSHIFT_METHODDEF \
686 {"ilshift", _PyCFunction_CAST(_operator_ilshift), METH_FASTCALL, _operator_ilshift__doc__},
687
688 static PyObject *
689 _operator_ilshift_impl(PyObject *module, PyObject *a, PyObject *b);
690
691 static PyObject *
_operator_ilshift(PyObject * module,PyObject * const * args,Py_ssize_t nargs)692 _operator_ilshift(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
693 {
694 PyObject *return_value = NULL;
695 PyObject *a;
696 PyObject *b;
697
698 if (!_PyArg_CheckPositional("ilshift", nargs, 2, 2)) {
699 goto exit;
700 }
701 a = args[0];
702 b = args[1];
703 return_value = _operator_ilshift_impl(module, a, b);
704
705 exit:
706 return return_value;
707 }
708
709 PyDoc_STRVAR(_operator_irshift__doc__,
710 "irshift($module, a, b, /)\n"
711 "--\n"
712 "\n"
713 "Same as a >>= b.");
714
715 #define _OPERATOR_IRSHIFT_METHODDEF \
716 {"irshift", _PyCFunction_CAST(_operator_irshift), METH_FASTCALL, _operator_irshift__doc__},
717
718 static PyObject *
719 _operator_irshift_impl(PyObject *module, PyObject *a, PyObject *b);
720
721 static PyObject *
_operator_irshift(PyObject * module,PyObject * const * args,Py_ssize_t nargs)722 _operator_irshift(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
723 {
724 PyObject *return_value = NULL;
725 PyObject *a;
726 PyObject *b;
727
728 if (!_PyArg_CheckPositional("irshift", nargs, 2, 2)) {
729 goto exit;
730 }
731 a = args[0];
732 b = args[1];
733 return_value = _operator_irshift_impl(module, a, b);
734
735 exit:
736 return return_value;
737 }
738
739 PyDoc_STRVAR(_operator_iand__doc__,
740 "iand($module, a, b, /)\n"
741 "--\n"
742 "\n"
743 "Same as a &= b.");
744
745 #define _OPERATOR_IAND_METHODDEF \
746 {"iand", _PyCFunction_CAST(_operator_iand), METH_FASTCALL, _operator_iand__doc__},
747
748 static PyObject *
749 _operator_iand_impl(PyObject *module, PyObject *a, PyObject *b);
750
751 static PyObject *
_operator_iand(PyObject * module,PyObject * const * args,Py_ssize_t nargs)752 _operator_iand(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
753 {
754 PyObject *return_value = NULL;
755 PyObject *a;
756 PyObject *b;
757
758 if (!_PyArg_CheckPositional("iand", nargs, 2, 2)) {
759 goto exit;
760 }
761 a = args[0];
762 b = args[1];
763 return_value = _operator_iand_impl(module, a, b);
764
765 exit:
766 return return_value;
767 }
768
769 PyDoc_STRVAR(_operator_ixor__doc__,
770 "ixor($module, a, b, /)\n"
771 "--\n"
772 "\n"
773 "Same as a ^= b.");
774
775 #define _OPERATOR_IXOR_METHODDEF \
776 {"ixor", _PyCFunction_CAST(_operator_ixor), METH_FASTCALL, _operator_ixor__doc__},
777
778 static PyObject *
779 _operator_ixor_impl(PyObject *module, PyObject *a, PyObject *b);
780
781 static PyObject *
_operator_ixor(PyObject * module,PyObject * const * args,Py_ssize_t nargs)782 _operator_ixor(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
783 {
784 PyObject *return_value = NULL;
785 PyObject *a;
786 PyObject *b;
787
788 if (!_PyArg_CheckPositional("ixor", nargs, 2, 2)) {
789 goto exit;
790 }
791 a = args[0];
792 b = args[1];
793 return_value = _operator_ixor_impl(module, a, b);
794
795 exit:
796 return return_value;
797 }
798
799 PyDoc_STRVAR(_operator_ior__doc__,
800 "ior($module, a, b, /)\n"
801 "--\n"
802 "\n"
803 "Same as a |= b.");
804
805 #define _OPERATOR_IOR_METHODDEF \
806 {"ior", _PyCFunction_CAST(_operator_ior), METH_FASTCALL, _operator_ior__doc__},
807
808 static PyObject *
809 _operator_ior_impl(PyObject *module, PyObject *a, PyObject *b);
810
811 static PyObject *
_operator_ior(PyObject * module,PyObject * const * args,Py_ssize_t nargs)812 _operator_ior(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
813 {
814 PyObject *return_value = NULL;
815 PyObject *a;
816 PyObject *b;
817
818 if (!_PyArg_CheckPositional("ior", nargs, 2, 2)) {
819 goto exit;
820 }
821 a = args[0];
822 b = args[1];
823 return_value = _operator_ior_impl(module, a, b);
824
825 exit:
826 return return_value;
827 }
828
829 PyDoc_STRVAR(_operator_concat__doc__,
830 "concat($module, a, b, /)\n"
831 "--\n"
832 "\n"
833 "Same as a + b, for a and b sequences.");
834
835 #define _OPERATOR_CONCAT_METHODDEF \
836 {"concat", _PyCFunction_CAST(_operator_concat), METH_FASTCALL, _operator_concat__doc__},
837
838 static PyObject *
839 _operator_concat_impl(PyObject *module, PyObject *a, PyObject *b);
840
841 static PyObject *
_operator_concat(PyObject * module,PyObject * const * args,Py_ssize_t nargs)842 _operator_concat(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
843 {
844 PyObject *return_value = NULL;
845 PyObject *a;
846 PyObject *b;
847
848 if (!_PyArg_CheckPositional("concat", nargs, 2, 2)) {
849 goto exit;
850 }
851 a = args[0];
852 b = args[1];
853 return_value = _operator_concat_impl(module, a, b);
854
855 exit:
856 return return_value;
857 }
858
859 PyDoc_STRVAR(_operator_iconcat__doc__,
860 "iconcat($module, a, b, /)\n"
861 "--\n"
862 "\n"
863 "Same as a += b, for a and b sequences.");
864
865 #define _OPERATOR_ICONCAT_METHODDEF \
866 {"iconcat", _PyCFunction_CAST(_operator_iconcat), METH_FASTCALL, _operator_iconcat__doc__},
867
868 static PyObject *
869 _operator_iconcat_impl(PyObject *module, PyObject *a, PyObject *b);
870
871 static PyObject *
_operator_iconcat(PyObject * module,PyObject * const * args,Py_ssize_t nargs)872 _operator_iconcat(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
873 {
874 PyObject *return_value = NULL;
875 PyObject *a;
876 PyObject *b;
877
878 if (!_PyArg_CheckPositional("iconcat", nargs, 2, 2)) {
879 goto exit;
880 }
881 a = args[0];
882 b = args[1];
883 return_value = _operator_iconcat_impl(module, a, b);
884
885 exit:
886 return return_value;
887 }
888
889 PyDoc_STRVAR(_operator_contains__doc__,
890 "contains($module, a, b, /)\n"
891 "--\n"
892 "\n"
893 "Same as b in a (note reversed operands).");
894
895 #define _OPERATOR_CONTAINS_METHODDEF \
896 {"contains", _PyCFunction_CAST(_operator_contains), METH_FASTCALL, _operator_contains__doc__},
897
898 static int
899 _operator_contains_impl(PyObject *module, PyObject *a, PyObject *b);
900
901 static PyObject *
_operator_contains(PyObject * module,PyObject * const * args,Py_ssize_t nargs)902 _operator_contains(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
903 {
904 PyObject *return_value = NULL;
905 PyObject *a;
906 PyObject *b;
907 int _return_value;
908
909 if (!_PyArg_CheckPositional("contains", nargs, 2, 2)) {
910 goto exit;
911 }
912 a = args[0];
913 b = args[1];
914 _return_value = _operator_contains_impl(module, a, b);
915 if ((_return_value == -1) && PyErr_Occurred()) {
916 goto exit;
917 }
918 return_value = PyBool_FromLong((long)_return_value);
919
920 exit:
921 return return_value;
922 }
923
924 PyDoc_STRVAR(_operator_indexOf__doc__,
925 "indexOf($module, a, b, /)\n"
926 "--\n"
927 "\n"
928 "Return the first index of b in a.");
929
930 #define _OPERATOR_INDEXOF_METHODDEF \
931 {"indexOf", _PyCFunction_CAST(_operator_indexOf), METH_FASTCALL, _operator_indexOf__doc__},
932
933 static Py_ssize_t
934 _operator_indexOf_impl(PyObject *module, PyObject *a, PyObject *b);
935
936 static PyObject *
_operator_indexOf(PyObject * module,PyObject * const * args,Py_ssize_t nargs)937 _operator_indexOf(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
938 {
939 PyObject *return_value = NULL;
940 PyObject *a;
941 PyObject *b;
942 Py_ssize_t _return_value;
943
944 if (!_PyArg_CheckPositional("indexOf", nargs, 2, 2)) {
945 goto exit;
946 }
947 a = args[0];
948 b = args[1];
949 _return_value = _operator_indexOf_impl(module, a, b);
950 if ((_return_value == -1) && PyErr_Occurred()) {
951 goto exit;
952 }
953 return_value = PyLong_FromSsize_t(_return_value);
954
955 exit:
956 return return_value;
957 }
958
959 PyDoc_STRVAR(_operator_countOf__doc__,
960 "countOf($module, a, b, /)\n"
961 "--\n"
962 "\n"
963 "Return the number of items in a which are, or which equal, b.");
964
965 #define _OPERATOR_COUNTOF_METHODDEF \
966 {"countOf", _PyCFunction_CAST(_operator_countOf), METH_FASTCALL, _operator_countOf__doc__},
967
968 static Py_ssize_t
969 _operator_countOf_impl(PyObject *module, PyObject *a, PyObject *b);
970
971 static PyObject *
_operator_countOf(PyObject * module,PyObject * const * args,Py_ssize_t nargs)972 _operator_countOf(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
973 {
974 PyObject *return_value = NULL;
975 PyObject *a;
976 PyObject *b;
977 Py_ssize_t _return_value;
978
979 if (!_PyArg_CheckPositional("countOf", nargs, 2, 2)) {
980 goto exit;
981 }
982 a = args[0];
983 b = args[1];
984 _return_value = _operator_countOf_impl(module, a, b);
985 if ((_return_value == -1) && PyErr_Occurred()) {
986 goto exit;
987 }
988 return_value = PyLong_FromSsize_t(_return_value);
989
990 exit:
991 return return_value;
992 }
993
994 PyDoc_STRVAR(_operator_getitem__doc__,
995 "getitem($module, a, b, /)\n"
996 "--\n"
997 "\n"
998 "Same as a[b].");
999
1000 #define _OPERATOR_GETITEM_METHODDEF \
1001 {"getitem", _PyCFunction_CAST(_operator_getitem), METH_FASTCALL, _operator_getitem__doc__},
1002
1003 static PyObject *
1004 _operator_getitem_impl(PyObject *module, PyObject *a, PyObject *b);
1005
1006 static PyObject *
_operator_getitem(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1007 _operator_getitem(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1008 {
1009 PyObject *return_value = NULL;
1010 PyObject *a;
1011 PyObject *b;
1012
1013 if (!_PyArg_CheckPositional("getitem", nargs, 2, 2)) {
1014 goto exit;
1015 }
1016 a = args[0];
1017 b = args[1];
1018 return_value = _operator_getitem_impl(module, a, b);
1019
1020 exit:
1021 return return_value;
1022 }
1023
1024 PyDoc_STRVAR(_operator_setitem__doc__,
1025 "setitem($module, a, b, c, /)\n"
1026 "--\n"
1027 "\n"
1028 "Same as a[b] = c.");
1029
1030 #define _OPERATOR_SETITEM_METHODDEF \
1031 {"setitem", _PyCFunction_CAST(_operator_setitem), METH_FASTCALL, _operator_setitem__doc__},
1032
1033 static PyObject *
1034 _operator_setitem_impl(PyObject *module, PyObject *a, PyObject *b,
1035 PyObject *c);
1036
1037 static PyObject *
_operator_setitem(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1038 _operator_setitem(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1039 {
1040 PyObject *return_value = NULL;
1041 PyObject *a;
1042 PyObject *b;
1043 PyObject *c;
1044
1045 if (!_PyArg_CheckPositional("setitem", nargs, 3, 3)) {
1046 goto exit;
1047 }
1048 a = args[0];
1049 b = args[1];
1050 c = args[2];
1051 return_value = _operator_setitem_impl(module, a, b, c);
1052
1053 exit:
1054 return return_value;
1055 }
1056
1057 PyDoc_STRVAR(_operator_delitem__doc__,
1058 "delitem($module, a, b, /)\n"
1059 "--\n"
1060 "\n"
1061 "Same as del a[b].");
1062
1063 #define _OPERATOR_DELITEM_METHODDEF \
1064 {"delitem", _PyCFunction_CAST(_operator_delitem), METH_FASTCALL, _operator_delitem__doc__},
1065
1066 static PyObject *
1067 _operator_delitem_impl(PyObject *module, PyObject *a, PyObject *b);
1068
1069 static PyObject *
_operator_delitem(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1070 _operator_delitem(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1071 {
1072 PyObject *return_value = NULL;
1073 PyObject *a;
1074 PyObject *b;
1075
1076 if (!_PyArg_CheckPositional("delitem", nargs, 2, 2)) {
1077 goto exit;
1078 }
1079 a = args[0];
1080 b = args[1];
1081 return_value = _operator_delitem_impl(module, a, b);
1082
1083 exit:
1084 return return_value;
1085 }
1086
1087 PyDoc_STRVAR(_operator_eq__doc__,
1088 "eq($module, a, b, /)\n"
1089 "--\n"
1090 "\n"
1091 "Same as a == b.");
1092
1093 #define _OPERATOR_EQ_METHODDEF \
1094 {"eq", _PyCFunction_CAST(_operator_eq), METH_FASTCALL, _operator_eq__doc__},
1095
1096 static PyObject *
1097 _operator_eq_impl(PyObject *module, PyObject *a, PyObject *b);
1098
1099 static PyObject *
_operator_eq(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1100 _operator_eq(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1101 {
1102 PyObject *return_value = NULL;
1103 PyObject *a;
1104 PyObject *b;
1105
1106 if (!_PyArg_CheckPositional("eq", nargs, 2, 2)) {
1107 goto exit;
1108 }
1109 a = args[0];
1110 b = args[1];
1111 return_value = _operator_eq_impl(module, a, b);
1112
1113 exit:
1114 return return_value;
1115 }
1116
1117 PyDoc_STRVAR(_operator_ne__doc__,
1118 "ne($module, a, b, /)\n"
1119 "--\n"
1120 "\n"
1121 "Same as a != b.");
1122
1123 #define _OPERATOR_NE_METHODDEF \
1124 {"ne", _PyCFunction_CAST(_operator_ne), METH_FASTCALL, _operator_ne__doc__},
1125
1126 static PyObject *
1127 _operator_ne_impl(PyObject *module, PyObject *a, PyObject *b);
1128
1129 static PyObject *
_operator_ne(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1130 _operator_ne(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1131 {
1132 PyObject *return_value = NULL;
1133 PyObject *a;
1134 PyObject *b;
1135
1136 if (!_PyArg_CheckPositional("ne", nargs, 2, 2)) {
1137 goto exit;
1138 }
1139 a = args[0];
1140 b = args[1];
1141 return_value = _operator_ne_impl(module, a, b);
1142
1143 exit:
1144 return return_value;
1145 }
1146
1147 PyDoc_STRVAR(_operator_lt__doc__,
1148 "lt($module, a, b, /)\n"
1149 "--\n"
1150 "\n"
1151 "Same as a < b.");
1152
1153 #define _OPERATOR_LT_METHODDEF \
1154 {"lt", _PyCFunction_CAST(_operator_lt), METH_FASTCALL, _operator_lt__doc__},
1155
1156 static PyObject *
1157 _operator_lt_impl(PyObject *module, PyObject *a, PyObject *b);
1158
1159 static PyObject *
_operator_lt(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1160 _operator_lt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1161 {
1162 PyObject *return_value = NULL;
1163 PyObject *a;
1164 PyObject *b;
1165
1166 if (!_PyArg_CheckPositional("lt", nargs, 2, 2)) {
1167 goto exit;
1168 }
1169 a = args[0];
1170 b = args[1];
1171 return_value = _operator_lt_impl(module, a, b);
1172
1173 exit:
1174 return return_value;
1175 }
1176
1177 PyDoc_STRVAR(_operator_le__doc__,
1178 "le($module, a, b, /)\n"
1179 "--\n"
1180 "\n"
1181 "Same as a <= b.");
1182
1183 #define _OPERATOR_LE_METHODDEF \
1184 {"le", _PyCFunction_CAST(_operator_le), METH_FASTCALL, _operator_le__doc__},
1185
1186 static PyObject *
1187 _operator_le_impl(PyObject *module, PyObject *a, PyObject *b);
1188
1189 static PyObject *
_operator_le(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1190 _operator_le(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1191 {
1192 PyObject *return_value = NULL;
1193 PyObject *a;
1194 PyObject *b;
1195
1196 if (!_PyArg_CheckPositional("le", nargs, 2, 2)) {
1197 goto exit;
1198 }
1199 a = args[0];
1200 b = args[1];
1201 return_value = _operator_le_impl(module, a, b);
1202
1203 exit:
1204 return return_value;
1205 }
1206
1207 PyDoc_STRVAR(_operator_gt__doc__,
1208 "gt($module, a, b, /)\n"
1209 "--\n"
1210 "\n"
1211 "Same as a > b.");
1212
1213 #define _OPERATOR_GT_METHODDEF \
1214 {"gt", _PyCFunction_CAST(_operator_gt), METH_FASTCALL, _operator_gt__doc__},
1215
1216 static PyObject *
1217 _operator_gt_impl(PyObject *module, PyObject *a, PyObject *b);
1218
1219 static PyObject *
_operator_gt(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1220 _operator_gt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1221 {
1222 PyObject *return_value = NULL;
1223 PyObject *a;
1224 PyObject *b;
1225
1226 if (!_PyArg_CheckPositional("gt", nargs, 2, 2)) {
1227 goto exit;
1228 }
1229 a = args[0];
1230 b = args[1];
1231 return_value = _operator_gt_impl(module, a, b);
1232
1233 exit:
1234 return return_value;
1235 }
1236
1237 PyDoc_STRVAR(_operator_ge__doc__,
1238 "ge($module, a, b, /)\n"
1239 "--\n"
1240 "\n"
1241 "Same as a >= b.");
1242
1243 #define _OPERATOR_GE_METHODDEF \
1244 {"ge", _PyCFunction_CAST(_operator_ge), METH_FASTCALL, _operator_ge__doc__},
1245
1246 static PyObject *
1247 _operator_ge_impl(PyObject *module, PyObject *a, PyObject *b);
1248
1249 static PyObject *
_operator_ge(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1250 _operator_ge(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1251 {
1252 PyObject *return_value = NULL;
1253 PyObject *a;
1254 PyObject *b;
1255
1256 if (!_PyArg_CheckPositional("ge", nargs, 2, 2)) {
1257 goto exit;
1258 }
1259 a = args[0];
1260 b = args[1];
1261 return_value = _operator_ge_impl(module, a, b);
1262
1263 exit:
1264 return return_value;
1265 }
1266
1267 PyDoc_STRVAR(_operator_pow__doc__,
1268 "pow($module, a, b, /)\n"
1269 "--\n"
1270 "\n"
1271 "Same as a ** b.");
1272
1273 #define _OPERATOR_POW_METHODDEF \
1274 {"pow", _PyCFunction_CAST(_operator_pow), METH_FASTCALL, _operator_pow__doc__},
1275
1276 static PyObject *
1277 _operator_pow_impl(PyObject *module, PyObject *a, PyObject *b);
1278
1279 static PyObject *
_operator_pow(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1280 _operator_pow(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1281 {
1282 PyObject *return_value = NULL;
1283 PyObject *a;
1284 PyObject *b;
1285
1286 if (!_PyArg_CheckPositional("pow", nargs, 2, 2)) {
1287 goto exit;
1288 }
1289 a = args[0];
1290 b = args[1];
1291 return_value = _operator_pow_impl(module, a, b);
1292
1293 exit:
1294 return return_value;
1295 }
1296
1297 PyDoc_STRVAR(_operator_ipow__doc__,
1298 "ipow($module, a, b, /)\n"
1299 "--\n"
1300 "\n"
1301 "Same as a **= b.");
1302
1303 #define _OPERATOR_IPOW_METHODDEF \
1304 {"ipow", _PyCFunction_CAST(_operator_ipow), METH_FASTCALL, _operator_ipow__doc__},
1305
1306 static PyObject *
1307 _operator_ipow_impl(PyObject *module, PyObject *a, PyObject *b);
1308
1309 static PyObject *
_operator_ipow(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1310 _operator_ipow(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1311 {
1312 PyObject *return_value = NULL;
1313 PyObject *a;
1314 PyObject *b;
1315
1316 if (!_PyArg_CheckPositional("ipow", nargs, 2, 2)) {
1317 goto exit;
1318 }
1319 a = args[0];
1320 b = args[1];
1321 return_value = _operator_ipow_impl(module, a, b);
1322
1323 exit:
1324 return return_value;
1325 }
1326
1327 PyDoc_STRVAR(_operator_index__doc__,
1328 "index($module, a, /)\n"
1329 "--\n"
1330 "\n"
1331 "Same as a.__index__()");
1332
1333 #define _OPERATOR_INDEX_METHODDEF \
1334 {"index", (PyCFunction)_operator_index, METH_O, _operator_index__doc__},
1335
1336 PyDoc_STRVAR(_operator_is___doc__,
1337 "is_($module, a, b, /)\n"
1338 "--\n"
1339 "\n"
1340 "Same as a is b.");
1341
1342 #define _OPERATOR_IS__METHODDEF \
1343 {"is_", _PyCFunction_CAST(_operator_is_), METH_FASTCALL, _operator_is___doc__},
1344
1345 static PyObject *
1346 _operator_is__impl(PyObject *module, PyObject *a, PyObject *b);
1347
1348 static PyObject *
_operator_is_(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1349 _operator_is_(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1350 {
1351 PyObject *return_value = NULL;
1352 PyObject *a;
1353 PyObject *b;
1354
1355 if (!_PyArg_CheckPositional("is_", nargs, 2, 2)) {
1356 goto exit;
1357 }
1358 a = args[0];
1359 b = args[1];
1360 return_value = _operator_is__impl(module, a, b);
1361
1362 exit:
1363 return return_value;
1364 }
1365
1366 PyDoc_STRVAR(_operator_is_not__doc__,
1367 "is_not($module, a, b, /)\n"
1368 "--\n"
1369 "\n"
1370 "Same as a is not b.");
1371
1372 #define _OPERATOR_IS_NOT_METHODDEF \
1373 {"is_not", _PyCFunction_CAST(_operator_is_not), METH_FASTCALL, _operator_is_not__doc__},
1374
1375 static PyObject *
1376 _operator_is_not_impl(PyObject *module, PyObject *a, PyObject *b);
1377
1378 static PyObject *
_operator_is_not(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1379 _operator_is_not(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1380 {
1381 PyObject *return_value = NULL;
1382 PyObject *a;
1383 PyObject *b;
1384
1385 if (!_PyArg_CheckPositional("is_not", nargs, 2, 2)) {
1386 goto exit;
1387 }
1388 a = args[0];
1389 b = args[1];
1390 return_value = _operator_is_not_impl(module, a, b);
1391
1392 exit:
1393 return return_value;
1394 }
1395
1396 PyDoc_STRVAR(_operator_length_hint__doc__,
1397 "length_hint($module, obj, default=0, /)\n"
1398 "--\n"
1399 "\n"
1400 "Return an estimate of the number of items in obj.\n"
1401 "\n"
1402 "This is useful for presizing containers when building from an iterable.\n"
1403 "\n"
1404 "If the object supports len(), the result will be exact.\n"
1405 "Otherwise, it may over- or under-estimate by an arbitrary amount.\n"
1406 "The result will be an integer >= 0.");
1407
1408 #define _OPERATOR_LENGTH_HINT_METHODDEF \
1409 {"length_hint", _PyCFunction_CAST(_operator_length_hint), METH_FASTCALL, _operator_length_hint__doc__},
1410
1411 static Py_ssize_t
1412 _operator_length_hint_impl(PyObject *module, PyObject *obj,
1413 Py_ssize_t default_value);
1414
1415 static PyObject *
_operator_length_hint(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1416 _operator_length_hint(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1417 {
1418 PyObject *return_value = NULL;
1419 PyObject *obj;
1420 Py_ssize_t default_value = 0;
1421 Py_ssize_t _return_value;
1422
1423 if (!_PyArg_CheckPositional("length_hint", nargs, 1, 2)) {
1424 goto exit;
1425 }
1426 obj = args[0];
1427 if (nargs < 2) {
1428 goto skip_optional;
1429 }
1430 {
1431 Py_ssize_t ival = -1;
1432 PyObject *iobj = _PyNumber_Index(args[1]);
1433 if (iobj != NULL) {
1434 ival = PyLong_AsSsize_t(iobj);
1435 Py_DECREF(iobj);
1436 }
1437 if (ival == -1 && PyErr_Occurred()) {
1438 goto exit;
1439 }
1440 default_value = ival;
1441 }
1442 skip_optional:
1443 _return_value = _operator_length_hint_impl(module, obj, default_value);
1444 if ((_return_value == -1) && PyErr_Occurred()) {
1445 goto exit;
1446 }
1447 return_value = PyLong_FromSsize_t(_return_value);
1448
1449 exit:
1450 return return_value;
1451 }
1452
1453 PyDoc_STRVAR(_operator__compare_digest__doc__,
1454 "_compare_digest($module, a, b, /)\n"
1455 "--\n"
1456 "\n"
1457 "Return \'a == b\'.\n"
1458 "\n"
1459 "This function uses an approach designed to prevent\n"
1460 "timing analysis, making it appropriate for cryptography.\n"
1461 "\n"
1462 "a and b must both be of the same type: either str (ASCII only),\n"
1463 "or any bytes-like object.\n"
1464 "\n"
1465 "Note: If a and b are of different lengths, or if an error occurs,\n"
1466 "a timing attack could theoretically reveal information about the\n"
1467 "types and lengths of a and b--but not their values.");
1468
1469 #define _OPERATOR__COMPARE_DIGEST_METHODDEF \
1470 {"_compare_digest", _PyCFunction_CAST(_operator__compare_digest), METH_FASTCALL, _operator__compare_digest__doc__},
1471
1472 static PyObject *
1473 _operator__compare_digest_impl(PyObject *module, PyObject *a, PyObject *b);
1474
1475 static PyObject *
_operator__compare_digest(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1476 _operator__compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1477 {
1478 PyObject *return_value = NULL;
1479 PyObject *a;
1480 PyObject *b;
1481
1482 if (!_PyArg_CheckPositional("_compare_digest", nargs, 2, 2)) {
1483 goto exit;
1484 }
1485 a = args[0];
1486 b = args[1];
1487 return_value = _operator__compare_digest_impl(module, a, b);
1488
1489 exit:
1490 return return_value;
1491 }
1492 /*[clinic end generated code: output=ddbba2cd943571eb input=a9049054013a1b77]*/
1493