Cython 3.2.6__py3-none-any.whl → 3.3.0a2.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of Cython might be problematic. Click here for more details.

Files changed (112) hide show
  1. Cython/Build/BuildExecutable.py +1 -14
  2. Cython/Build/Dependencies.py +6 -44
  3. Cython/Build/Inline.py +7 -3
  4. Cython/Build/IpythonMagic.py +0 -1
  5. Cython/Build/SharedModule.py +1 -2
  6. Cython/Build/Tests/TestCythonizeArgsParser.py +6 -6
  7. Cython/Build/Tests/TestDependencies.py +3 -3
  8. Cython/Build/Tests/TestInline.py +3 -3
  9. Cython/Build/Tests/TestIpythonMagic.py +35 -19
  10. Cython/Build/Tests/TestStripLiterals.py +2 -2
  11. Cython/Compiler/Buffer.py +5 -5
  12. Cython/Compiler/Builtin.py +57 -46
  13. Cython/Compiler/Code.pxd +12 -9
  14. Cython/Compiler/Code.py +220 -94
  15. Cython/Compiler/Dataclass.py +78 -52
  16. Cython/Compiler/Errors.py +21 -8
  17. Cython/Compiler/ExprNodes.py +871 -459
  18. Cython/Compiler/FlowControl.pxd +8 -6
  19. Cython/Compiler/FlowControl.py +111 -8
  20. Cython/Compiler/FusedNode.py +17 -12
  21. Cython/Compiler/Lexicon.py +123 -122
  22. Cython/Compiler/Main.py +3 -4
  23. Cython/Compiler/MatchCaseNodes.py +1948 -10
  24. Cython/Compiler/MemoryView.py +62 -33
  25. Cython/Compiler/ModuleNode.py +559 -283
  26. Cython/Compiler/Naming.py +4 -0
  27. Cython/Compiler/Nodes.py +333 -197
  28. Cython/Compiler/Optimize.py +268 -112
  29. Cython/Compiler/Options.py +0 -5
  30. Cython/Compiler/ParseTreeTransforms.pxd +2 -1
  31. Cython/Compiler/ParseTreeTransforms.py +180 -76
  32. Cython/Compiler/Parsing.py +55 -38
  33. Cython/Compiler/PyrexTypes.py +364 -128
  34. Cython/Compiler/Scanning.pxd +27 -5
  35. Cython/Compiler/Scanning.py +24 -14
  36. Cython/Compiler/StringEncoding.py +1 -2
  37. Cython/Compiler/Symtab.py +27 -19
  38. Cython/Compiler/Tests/TestBuiltin.py +41 -6
  39. Cython/Compiler/Tests/TestCmdLine.py +3 -2
  40. Cython/Compiler/Tests/TestCode.py +4 -3
  41. Cython/Compiler/Tests/TestFlowControl.py +2 -2
  42. Cython/Compiler/Tests/TestParseTreeTransforms.py +2 -2
  43. Cython/Compiler/Tests/TestScanning.py +2 -4
  44. Cython/Compiler/Tests/TestSignatureMatching.py +3 -3
  45. Cython/Compiler/Tests/TestStringEncoding.py +2 -3
  46. Cython/Compiler/Tests/TestTypes.py +46 -3
  47. Cython/Compiler/Tests/TestUtilityLoad.py +4 -4
  48. Cython/Compiler/TypeInference.py +20 -0
  49. Cython/Compiler/TypeSlots.py +171 -16
  50. Cython/Compiler/UtilNodes.py +24 -0
  51. Cython/Compiler/UtilityCode.py +1 -0
  52. Cython/Compiler/Visitor.pxd +1 -1
  53. Cython/Compiler/Visitor.py +3 -2
  54. Cython/Debugger/Tests/TestLibCython.py +7 -2
  55. Cython/Debugger/Tests/test_libcython_in_gdb.py +4 -2
  56. Cython/Debugger/Tests/test_libpython_in_gdb.py +1 -1
  57. Cython/Includes/cpython/array.pxd +5 -5
  58. Cython/Includes/cpython/dict.pxd +1 -6
  59. Cython/Includes/cpython/float.pxd +19 -10
  60. Cython/Includes/cpython/frozendict.pxd +37 -0
  61. Cython/Includes/cpython/long.pxd +31 -0
  62. Cython/Includes/cpython/object.pxd +9 -12
  63. Cython/Includes/cpython/sentinel.pxd +17 -0
  64. Cython/Includes/cpython/type.pxd +93 -0
  65. Cython/Includes/libcpp/exception.pxd +90 -0
  66. Cython/LZSS.py +170 -0
  67. Cython/Shadow.py +550 -73
  68. Cython/StringIOTree.py +1 -2
  69. Cython/Tempita/_tempita.py +45 -46
  70. Cython/TestUtils.py +50 -8
  71. Cython/Tests/TestCythonUtils.py +2 -2
  72. Cython/Tests/TestJediTyper.py +1 -1
  73. Cython/Tests/TestShadow.py +7 -5
  74. Cython/Tests/TestStringIOTree.py +4 -3
  75. Cython/Tests/TestTestUtils.py +2 -3
  76. Cython/Utility/AsyncGen.c +59 -19
  77. Cython/Utility/Buffer.c +4 -3
  78. Cython/Utility/Builtins.c +139 -17
  79. Cython/Utility/CConvert.pyx +27 -12
  80. Cython/Utility/CommonStructures.c +55 -37
  81. Cython/Utility/Coroutine.c +112 -68
  82. Cython/Utility/CythonFunction.c +607 -330
  83. Cython/Utility/Embed.c +8 -0
  84. Cython/Utility/Exceptions.c +20 -3
  85. Cython/Utility/ExtensionTypes.c +414 -224
  86. Cython/Utility/FunctionArguments.c +83 -81
  87. Cython/Utility/ImportExport.c +72 -61
  88. Cython/Utility/MatchCase.c +979 -0
  89. Cython/Utility/MatchCase_Cy.pyx +12 -0
  90. Cython/Utility/MemoryView.pxd +9 -88
  91. Cython/Utility/MemoryView.pyx +173 -61
  92. Cython/Utility/MemoryView_C.c +3 -3
  93. Cython/Utility/ModuleSetupCode.c +306 -157
  94. Cython/Utility/ObjectHandling.c +483 -404
  95. Cython/Utility/Optimize.c +1117 -164
  96. Cython/Utility/Overflow.c +3 -9
  97. Cython/Utility/Profile.c +4 -0
  98. Cython/Utility/StringTools.c +187 -149
  99. Cython/Utility/Synchronization.c +39 -0
  100. Cython/Utility/TString.c +24 -13
  101. Cython/Utility/TypeConversion.c +405 -250
  102. Cython/Utility/arrayarray.h +24 -22
  103. Cython/Utils.py +11 -23
  104. Cython/__init__.py +3 -1
  105. {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/METADATA +14 -33
  106. {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/RECORD +109 -107
  107. {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/WHEEL +1 -1
  108. Cython/Shadow.pyi +0 -521
  109. Cython/Utility/Printing.c +0 -86
  110. Cython/__init__.pyi +0 -7
  111. {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/entry_points.txt +0 -0
  112. {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/top_level.txt +0 -0
@@ -230,6 +230,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *); /*pro
230
230
  /////////////// IterNext ///////////////
231
231
  //@requires: Exceptions.c::PyThreadStateGet
232
232
  //@requires: Exceptions.c::PyErrFetchRestore
233
+ //@requires: RaiseErrorWithObjectType
233
234
  //@requires: GetBuiltinName
234
235
  //@requires: IterNextPlain
235
236
 
@@ -254,10 +255,8 @@ static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
254
255
  }
255
256
 
256
257
  static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
257
- __Pyx_TypeName iterator_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(iterator));
258
- PyErr_Format(PyExc_TypeError,
259
- __Pyx_FMT_TYPENAME " object is not an iterator", iterator_type_name);
260
- __Pyx_DECREF_TypeName(iterator_type_name);
258
+ __Pyx_RaiseTypeErrorWithObjectType(
259
+ __Pyx_FMT_TYPENAME " object is not an iterator", iterator);
261
260
  }
262
261
 
263
262
  // originally copied from Py3's builtin_next()
@@ -335,6 +334,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *k
335
334
  // //@requires: GetItemInt - added in IndexNode as it uses templating.
336
335
  //@requires: PyObjectGetAttrStrNoError
337
336
  //@requires: PyObjectCallOneArg
337
+ //@requires: RaiseErrorWithObjectType
338
338
 
339
339
  #if CYTHON_USE_TYPE_SLOTS
340
340
  static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject *index) {
@@ -343,27 +343,28 @@ static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject *index) {
343
343
  Py_ssize_t key_value;
344
344
  key_value = __Pyx_PyIndex_AsSsize_t(index);
345
345
  if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
346
- return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1, 1);
346
+ return __Pyx_GetItemInt_Fast(obj, key_value, 1, 1, 1);
347
347
  }
348
348
 
349
349
  // Error handling code -- only manage OverflowError differently.
350
350
  if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
351
- __Pyx_TypeName index_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(index));
352
351
  PyErr_Clear();
353
- PyErr_Format(PyExc_IndexError,
354
- "cannot fit '" __Pyx_FMT_TYPENAME "' into an index-sized integer", index_type_name);
355
- __Pyx_DECREF_TypeName(index_type_name);
352
+ __Pyx_RaiseErrorWithObjectType(
353
+ PyExc_IndexError,
354
+ "cannot fit '" __Pyx_FMT_TYPENAME "' into an index-sized integer",
355
+ index);
356
356
  }
357
357
  return NULL;
358
358
  }
359
359
 
360
360
  static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) {
361
- __Pyx_TypeName obj_type_name;
362
361
  // Handles less common slow-path checks for GetItem
363
362
  if (likely(PyType_Check(obj))) {
364
363
  PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(obj, PYIDENT("__class_getitem__"));
365
364
  if (!meth) {
366
- PyErr_Clear();
365
+ if (PyErr_Occurred()) {
366
+ return NULL;
367
+ }
367
368
  } else {
368
369
  PyObject *result = __Pyx_PyObject_CallOneArg(meth, key);
369
370
  Py_DECREF(meth);
@@ -371,10 +372,8 @@ static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) {
371
372
  }
372
373
  }
373
374
 
374
- obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
375
- PyErr_Format(PyExc_TypeError,
376
- "'" __Pyx_FMT_TYPENAME "' object is not subscriptable", obj_type_name);
377
- __Pyx_DECREF_TypeName(obj_type_name);
375
+ __Pyx_RaiseTypeErrorWithObjectType(
376
+ "'" __Pyx_FMT_TYPENAME "' object is not subscriptable", obj);
378
377
  return NULL;
379
378
  }
380
379
 
@@ -395,12 +394,13 @@ static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key) {
395
394
 
396
395
 
397
396
  /////////////// DictGetItem.proto ///////////////
397
+ //@requires: Builtins.c::PyFrozenDict
398
398
 
399
399
  #if !CYTHON_COMPILING_IN_PYPY
400
400
  static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);/*proto*/
401
401
 
402
402
  #define __Pyx_PyObject_Dict_GetItem(obj, name) \
403
- (likely(PyDict_CheckExact(obj)) ? \
403
+ (likely(__Pyx_PyAnyDict_CheckExact(obj)) ? \
404
404
  __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
405
405
 
406
406
  #else
@@ -430,17 +430,44 @@ static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
430
430
  }
431
431
  #endif
432
432
 
433
+
434
+ /////////////// GetItemInt_wraparound.proto ///////////////
435
+
436
+ #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
437
+ static int __Pyx_GetItemInt_wraparound(PyObject *o, PySequenceMethods *sm, Py_ssize_t *i);
438
+ #endif
439
+
440
+ /////////////// GettItemInt_wraparound ///////////////
441
+
442
+ #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
443
+ static int __Pyx_GetItemInt_wraparound(PyObject *o, PySequenceMethods *sm, Py_ssize_t *i) {
444
+ assert(*i < 0);
445
+ if (likely(sm->sq_length)) {
446
+ Py_ssize_t l = sm->sq_length(o);
447
+ if (likely(l >= 0)) {
448
+ *i += l;
449
+ } else {
450
+ // if length > max(Py_ssize_t), maybe the object can wrap around itself?
451
+ if (!PyErr_ExceptionMatches(PyExc_OverflowError))
452
+ return -1;
453
+ PyErr_Clear();
454
+ }
455
+ }
456
+ return 0;
457
+ }
458
+ #endif
459
+
460
+
433
461
  /////////////// GetItemInt.proto ///////////////
434
462
  //@substitute: tempita
435
463
 
436
- #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared) \
464
+ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, wraparound, boundscheck, has_gil, unsafe_shared) \
437
465
  (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
438
- __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck, unsafe_shared) : \
439
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \
440
- __Pyx_GetItemInt_Generic(o, to_py_func(i))))
466
+ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) : \
467
+ __Pyx_GetItemInt_Generic(o, to_py_func(i)))
441
468
 
442
469
  {{for type in ['List', 'Tuple']}}
443
- #define __Pyx_GetItemInt_{{type}}(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared) \
470
+ #define __Pyx_GetItemInt_{{type}}(o, i, type, is_signed, to_py_func, wraparound, boundscheck, has_gil, unsafe_shared) \
444
471
  (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
445
472
  __Pyx_GetItemInt_{{type}}_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) : \
446
473
  (PyErr_SetString(PyExc_IndexError, "{{ type.lower() }} index out of range"), (PyObject*)NULL))
@@ -451,10 +478,12 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_{{type}}_Fast(PyObject *o, Py_ss
451
478
 
452
479
  static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
453
480
  static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
454
- int is_list, int wraparound, int boundscheck, int unsafe_shared);
481
+ int wraparound, int boundscheck, int unsafe_shared);
455
482
 
456
483
  /////////////// GetItemInt ///////////////
457
484
  //@substitute: tempita
485
+ //@requires: GettItemInt_wraparound
486
+ //@requires: Builtins.c::PyFrozenDict
458
487
 
459
488
  static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
460
489
  PyObject *r;
@@ -492,61 +521,72 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_{{type}}_Fast(PyObject *o, Py_ss
492
521
  }
493
522
  {{endfor}}
494
523
 
495
- static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
524
+ #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
525
+ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast_mapping(PyObject *o, binaryfunc getitem, Py_ssize_t i) {
526
+ PyObject *r, *key = PyLong_FromSsize_t(i);
527
+ if (unlikely(!key)) return NULL;
528
+ r = getitem(o, key);
529
+ Py_DECREF(key);
530
+ return r;
531
+ }
532
+ #endif
533
+
534
+ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
496
535
  int wraparound, int boundscheck, int unsafe_shared) {
497
536
  CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
498
- #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
499
- if (is_list || PyList_CheckExact(o)) {
500
- // We specifically aren't worrying about thread-safety issues from the delay between getting the size
501
- // and using the size because Python itself doesn't either. If we have boundschecking on they'll
502
- // be caught eventually.
503
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
504
- if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)) {
505
- return __Pyx_PyList_GetItemRefFast(o, n, unsafe_shared);
506
- } else if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
507
- return __Pyx_NewRef(PyList_GET_ITEM(o, n));
508
- }
537
+ #if CYTHON_ASSUME_SAFE_SIZE
538
+ if (PyList_CheckExact(o)) {
539
+ return __Pyx_GetItemInt_List_Fast(o, i, wraparound, boundscheck, unsafe_shared);
509
540
  } else
510
541
  #if !CYTHON_AVOID_BORROWED_REFS
511
542
  if (PyTuple_CheckExact(o)) {
512
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
513
- if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
514
- return __Pyx_NewRef(PyTuple_GET_ITEM(o, n));
515
- }
543
+ return __Pyx_GetItemInt_Tuple_Fast(o, i, wraparound, boundscheck, unsafe_shared);
516
544
  } else
517
545
  #endif
546
+ #else
547
+ if ((!wraparound || i >= 0) & PyList_CheckExact(o)) {
548
+ return __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared);
549
+ } else
518
550
  #endif
519
551
  #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
552
+ // This dict check is so cheap after the other type checks above that it would be costly *not* to do it.
553
+ if (__Pyx_PyAnyDict_CheckExact(o)) {
554
+ return __Pyx_GetItemInt_Fast_mapping(o, PyDict_Type.tp_as_mapping->mp_subscript, i);
555
+ } else
520
556
  {
521
557
  // inlined PySequence_GetItem() + special cased length overflow
522
- PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
523
- PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
524
- if (!is_list && mm && mm->mp_subscript) {
525
- PyObject *r, *key = PyLong_FromSsize_t(i);
526
- if (unlikely(!key)) return NULL;
527
- r = mm->mp_subscript(o, key);
528
- Py_DECREF(key);
529
- return r;
558
+ PyTypeObject *obj_type = Py_TYPE(o);
559
+
560
+ int seq_or_mapping = __Pyx_PyType_GetFlags(obj_type) & (Py_TPFLAGS_SEQUENCE|Py_TPFLAGS_MAPPING);
561
+
562
+ // We prefer sq_item() if type has Py_TPFLAGS_SEQUENCE,
563
+ // but still try mp_subscript() if that fails.
564
+ // We repeat the calls to __Pyx_GetItemInt_Fast_mapping() rather than
565
+ // the sequence access because the latter may result in more code,
566
+ // thus potentially hindering the inlining.
567
+ if (seq_or_mapping != Py_TPFLAGS_SEQUENCE) {
568
+ PyMappingMethods *mm = obj_type->tp_as_mapping;
569
+ if (mm && mm->mp_subscript)
570
+ return __Pyx_GetItemInt_Fast_mapping(o, mm->mp_subscript, i);
530
571
  }
531
- if (is_list || likely(sm && sm->sq_item)) {
532
- if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
533
- Py_ssize_t l = sm->sq_length(o);
534
- if (likely(l >= 0)) {
535
- i += l;
536
- } else {
537
- // if length > max(Py_ssize_t), maybe the object can wrap around itself?
538
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
539
- return NULL;
540
- PyErr_Clear();
541
- }
542
- }
572
+
573
+ PySequenceMethods *sm = obj_type->tp_as_sequence;
574
+ if (likely(sm && sm->sq_item)) {
575
+ if (wraparound && (i < 0) && unlikely(__Pyx_GetItemInt_wraparound(o, sm, &i) == -1))
576
+ return NULL;
543
577
  return sm->sq_item(o, i);
544
578
  }
579
+
580
+ if (seq_or_mapping == Py_TPFLAGS_SEQUENCE) {
581
+ PyMappingMethods *mm = obj_type->tp_as_mapping;
582
+ if (likely(mm && mm->mp_subscript))
583
+ return __Pyx_GetItemInt_Fast_mapping(o, mm->mp_subscript, i);
584
+ }
545
585
  }
546
586
  #else
547
587
  // PySequence_GetItem behaves differently to PyObject_GetItem for i<0
548
588
  // and possibly some other cases so can't generally be substituted
549
- if (is_list || !PyMapping_Check(o)) {
589
+ if (!PyMapping_Check(o)) {
550
590
  return PySequence_GetItem(o, i);
551
591
  }
552
592
  #endif
@@ -555,19 +595,20 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
555
595
  return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
556
596
  }
557
597
 
598
+
558
599
  /////////////// SetItemInt.proto ///////////////
559
600
 
560
- #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared) \
601
+ #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, wraparound, boundscheck, has_gil, unsafe_shared) \
561
602
  (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
562
- __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck, unsafe_shared) : \
563
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) : \
564
- __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
603
+ __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, wraparound, boundscheck, unsafe_shared) : \
604
+ __Pyx_SetItemInt_Generic(o, to_py_func(i), v))
565
605
 
566
606
  static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
567
607
  static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
568
- int is_list, int wraparound, int boundscheck, int unsafe_shared);
608
+ int wraparound, int boundscheck, int unsafe_shared);
569
609
 
570
610
  /////////////// SetItemInt ///////////////
611
+ //@requires: GettItemInt_wraparound
571
612
 
572
613
  static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
573
614
  int r;
@@ -577,11 +618,21 @@ static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
577
618
  return r;
578
619
  }
579
620
 
580
- static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
621
+ #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
622
+ static CYTHON_INLINE int __Pyx_SetItemInt_Fast_mapping(PyObject *o, objobjargproc setitem, Py_ssize_t i, PyObject *value) {
623
+ PyObject *key = PyLong_FromSsize_t(i);
624
+ if (unlikely(!key)) return -1;
625
+ int r = setitem(o, key, value);
626
+ Py_DECREF(key);
627
+ return r;
628
+ }
629
+ #endif
630
+
631
+ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
581
632
  int wraparound, int boundscheck, int unsafe_shared) {
582
633
  CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
583
634
  #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE && !CYTHON_AVOID_BORROWED_REFS
584
- if (is_list || PyList_CheckExact(o)) {
635
+ if (PyList_CheckExact(o)) {
585
636
  Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
586
637
  if ((CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS && !__Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared))) {
587
638
  Py_INCREF(v);
@@ -597,37 +648,43 @@ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObje
597
648
  } else
598
649
  #endif
599
650
  #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
651
+ if (PyDict_CheckExact(o)) {
652
+ return __Pyx_SetItemInt_Fast_mapping(o, PyDict_Type.tp_as_mapping->mp_ass_subscript, i, v);
653
+ } else
600
654
  {
601
655
  // inlined PySequence_SetItem() + special cased length overflow
602
- PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
603
- PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
604
- if (!is_list && mm && mm->mp_ass_subscript) {
605
- int r;
606
- PyObject *key = PyLong_FromSsize_t(i);
607
- if (unlikely(!key)) return -1;
608
- r = mm->mp_ass_subscript(o, key, v);
609
- Py_DECREF(key);
610
- return r;
656
+ PyTypeObject *obj_type = Py_TYPE(o);
657
+
658
+ int seq_or_mapping = __Pyx_PyType_GetFlags(obj_type) & (Py_TPFLAGS_SEQUENCE|Py_TPFLAGS_MAPPING);
659
+
660
+ // We prefer sq_ass_item() if type has Py_TPFLAGS_SEQUENCE,
661
+ // but still try mp_ass_subscript() if that fails.
662
+ // We repeat the calls to __Pyx_GetItemInt_Fast_mapping() rather than
663
+ // the sequence access because the latter may result in more code,
664
+ // thus potentially hindering the inlining.
665
+ if (seq_or_mapping != Py_TPFLAGS_SEQUENCE) {
666
+ PyMappingMethods *mm = obj_type->tp_as_mapping;
667
+ if (mm && mm->mp_ass_subscript)
668
+ return __Pyx_SetItemInt_Fast_mapping(o, mm->mp_ass_subscript, i, v);
611
669
  }
612
- if (is_list || likely(sm && sm->sq_ass_item)) {
613
- if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
614
- Py_ssize_t l = sm->sq_length(o);
615
- if (likely(l >= 0)) {
616
- i += l;
617
- } else {
618
- // if length > max(Py_ssize_t), maybe the object can wrap around itself?
619
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
620
- return -1;
621
- PyErr_Clear();
622
- }
623
- }
670
+
671
+ PySequenceMethods *sm = obj_type->tp_as_sequence;
672
+ if (likely(sm && sm->sq_ass_item)) {
673
+ if (wraparound && (i < 0) && unlikely(__Pyx_GetItemInt_wraparound(o, sm, &i) == -1))
674
+ return -1;
624
675
  return sm->sq_ass_item(o, i, v);
625
676
  }
677
+
678
+ if (seq_or_mapping == Py_TPFLAGS_SEQUENCE) {
679
+ PyMappingMethods *mm = obj_type->tp_as_mapping;
680
+ if (likely(mm && mm->mp_ass_subscript))
681
+ return __Pyx_SetItemInt_Fast_mapping(o, mm->mp_ass_subscript, i, v);
682
+ }
626
683
  }
627
684
  #else
628
685
  // PySequence_SetItem behaves differently to PyObject_SetItem for i<0
629
686
  // and possibly some other cases, so can't generally be substituted.
630
- if (is_list || !PyMapping_Check(o)) {
687
+ if (!PyMapping_Check(o)) {
631
688
  return PySequence_SetItem(o, i, v);
632
689
  }
633
690
  #endif
@@ -639,17 +696,16 @@ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObje
639
696
 
640
697
  /////////////// DelItemInt.proto ///////////////
641
698
 
642
- #define __Pyx_DelItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared) \
699
+ #define __Pyx_DelItemInt(o, i, type, is_signed, to_py_func, wraparound, boundscheck, has_gil, unsafe_shared) \
643
700
  (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
644
- __Pyx_DelItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound) : \
645
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) : \
646
- __Pyx_DelItem_Generic(o, to_py_func(i))))
701
+ __Pyx_DelItemInt_Fast(o, (Py_ssize_t)i, wraparound) : \
702
+ __Pyx_DelItem_Generic(o, to_py_func(i)))
647
703
 
648
704
  static int __Pyx_DelItem_Generic(PyObject *o, PyObject *j);
649
- static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
650
- int is_list, int wraparound);
705
+ static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i, int wraparound);
651
706
 
652
707
  /////////////// DelItemInt ///////////////
708
+ //@requires: GettItemInt_wraparound
653
709
 
654
710
  static int __Pyx_DelItem_Generic(PyObject *o, PyObject *j) {
655
711
  int r;
@@ -659,37 +715,55 @@ static int __Pyx_DelItem_Generic(PyObject *o, PyObject *j) {
659
715
  return r;
660
716
  }
661
717
 
662
- static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
663
- int is_list, CYTHON_NCP_UNUSED int wraparound) {
664
- #if !CYTHON_USE_TYPE_SLOTS
665
- // PySequence_DelItem behaves differently to PyObject_DelItem for i<0
666
- // and possibly some other cases so can't generally be substituted
667
- if (is_list || !PyMapping_Check(o)) {
668
- return PySequence_DelItem(o, i);
669
- }
670
- #else
718
+ #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
719
+ static CYTHON_INLINE int __Pyx_DelItemInt_Fast_mapping(PyObject *o, objobjargproc setitem, Py_ssize_t i) {
720
+ PyObject *key = PyLong_FromSsize_t(i);
721
+ if (unlikely(!key)) return -1;
722
+ int r = setitem(o, key, (PyObject*) NULL);
723
+ Py_DECREF(key);
724
+ return r;
725
+ }
726
+ #endif
727
+
728
+ static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i, int wraparound) {
729
+ #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
671
730
  // inlined PySequence_DelItem() + special cased length overflow
672
- PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
673
- PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
674
- if ((!is_list) && mm && mm->mp_ass_subscript) {
675
- PyObject *key = PyLong_FromSsize_t(i);
676
- return likely(key) ? mm->mp_ass_subscript(o, key, (PyObject *)NULL) : -1;
731
+ PyTypeObject *obj_type = Py_TYPE(o);
732
+
733
+ int seq_or_mapping = __Pyx_PyType_GetFlags(obj_type) & (Py_TPFLAGS_SEQUENCE|Py_TPFLAGS_MAPPING);
734
+
735
+ // We prefer sq_ass_item() if type has Py_TPFLAGS_SEQUENCE,
736
+ // but still try mp_ass_subscript() if that fails.
737
+ // We repeat the calls to __Pyx_GetItemInt_Fast_mapping() rather than
738
+ // the sequence access because the latter may result in more code,
739
+ // thus potentially hindering the inlining.
740
+ if (seq_or_mapping != Py_TPFLAGS_SEQUENCE) {
741
+ PyMappingMethods *mm = obj_type->tp_as_mapping;
742
+ if (mm && mm->mp_ass_subscript)
743
+ return __Pyx_DelItemInt_Fast_mapping(o, mm->mp_ass_subscript, i);
677
744
  }
745
+
746
+ PySequenceMethods *sm = obj_type->tp_as_sequence;
678
747
  if (likely(sm && sm->sq_ass_item)) {
679
- if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
680
- Py_ssize_t l = sm->sq_length(o);
681
- if (likely(l >= 0)) {
682
- i += l;
683
- } else {
684
- // if length > max(Py_ssize_t), maybe the object can wrap around itself?
685
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
686
- return -1;
687
- PyErr_Clear();
688
- }
689
- }
748
+ if (wraparound && (i < 0) && unlikely(__Pyx_GetItemInt_wraparound(o, sm, &i) == -1))
749
+ return -1;
690
750
  return sm->sq_ass_item(o, i, (PyObject *)NULL);
691
751
  }
752
+
753
+ if (seq_or_mapping == Py_TPFLAGS_SEQUENCE) {
754
+ PyMappingMethods *mm = obj_type->tp_as_mapping;
755
+ if (likely(mm && mm->mp_ass_subscript))
756
+ return __Pyx_DelItemInt_Fast_mapping(o, mm->mp_ass_subscript, i);
757
+ }
758
+ #else
759
+ (void) wraparound;
760
+ // PySequence_DelItem behaves differently to PyObject_DelItem for i<0
761
+ // and possibly some other cases so can't generally be substituted
762
+ if (!PyMapping_Check(o)) {
763
+ return PySequence_DelItem(o, i);
764
+ }
692
765
  #endif
766
+
693
767
  return __Pyx_DelItem_Generic(o, PyLong_FromSsize_t(i));
694
768
  }
695
769
 
@@ -714,6 +788,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
714
788
  {{endif}}
715
789
 
716
790
  /////////////// SliceObject ///////////////
791
+ //@requires: RaiseErrorWithObjectType
717
792
 
718
793
  {{if access == 'Get'}}
719
794
  static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
@@ -723,7 +798,6 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value,
723
798
  Py_ssize_t cstart, Py_ssize_t cstop,
724
799
  PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
725
800
  int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
726
- __Pyx_TypeName obj_type_name;
727
801
  #if CYTHON_USE_TYPE_SLOTS
728
802
  PyMappingMethods* mp = Py_TYPE(obj)->tp_as_mapping;
729
803
  {{if access == 'Get'}}
@@ -731,6 +805,9 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value,
731
805
  {{else}}
732
806
  if (likely(mp && mp->mp_ass_subscript))
733
807
  {{endif}}
808
+ #else
809
+ // Avoid a C warning about unused error handling code below.
810
+ if ((1))
734
811
  #endif
735
812
  {
736
813
  {{if access == 'Get'}}PyObject*{{else}}int{{endif}} result;
@@ -781,55 +858,43 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value,
781
858
  Py_DECREF(py_slice);
782
859
  }
783
860
  return result;
784
- }
785
- obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
786
- PyErr_Format(PyExc_TypeError,
861
+ } else {
787
862
  {{if access == 'Get'}}
788
- "'" __Pyx_FMT_TYPENAME "' object is unsliceable", obj_type_name);
863
+ __Pyx_RaiseTypeErrorWithObjectType(
864
+ "'" __Pyx_FMT_TYPENAME "' object is unsliceable", obj);
789
865
  {{else}}
790
- "'" __Pyx_FMT_TYPENAME "' object does not support slice %.10s",
791
- obj_type_name, value ? "assignment" : "deletion");
866
+ __Pyx_RaiseTypeErrorWithObjectType(
867
+ (value) ?
868
+ "'" __Pyx_FMT_TYPENAME "' object does not support slice assignment" :
869
+ "'" __Pyx_FMT_TYPENAME "' object does not support slice deletion",
870
+ obj);
792
871
  {{endif}}
793
- __Pyx_DECREF_TypeName(obj_type_name);
872
+ }
794
873
 
795
874
  bad:
796
875
  return {{if access == 'Get'}}NULL{{else}}-1{{endif}};
797
876
  }
798
877
 
799
878
 
800
- /////////////// TupleAndListFromArray.proto ///////////////
879
+ /////////////// TupleFromArray.proto //////////////////////
880
+ //@requires: TupleOrListFromArrayImpl{"Type": "Tuple"}
881
+
882
+ // This block only exists to require the tempita utility code
883
+
884
+ /////////////// ListFromArray.proto //////////////////////
885
+ //@requires: TupleOrListFromArrayImpl{"Type": "List"}
886
+
887
+ // This block only exists to require the tempita utility code
888
+
889
+ /////////////// CopyObjectArray.proto /////////////////
801
890
 
802
891
  #if CYTHON_COMPILING_IN_CPYTHON
803
- static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n);
804
- #endif
805
- #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_METH_FASTCALL
806
- static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n);
892
+ static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length); /* proto */
807
893
  #endif
808
894
 
895
+ /////////////// CopyObjectArray ///////////////////////
809
896
 
810
- /////////////// TupleAndListFromArray ///////////////
811
-
812
- #if !CYTHON_COMPILING_IN_CPYTHON && CYTHON_METH_FASTCALL
813
- static CYTHON_INLINE PyObject *
814
- __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
815
- {
816
- PyObject *res;
817
- Py_ssize_t i;
818
- if (n <= 0) {
819
- return __Pyx_NewRef(EMPTY(tuple));
820
- }
821
- res = PyTuple_New(n);
822
- if (unlikely(res == NULL)) return NULL;
823
- for (i = 0; i < n; i++) {
824
- Py_INCREF(src[i]);
825
- if (unlikely(__Pyx_PyTuple_SET_ITEM(res, i, src[i]) < (0))) {
826
- Py_DECREF(res);
827
- return NULL;
828
- }
829
- }
830
- return res;
831
- }
832
- #elif CYTHON_COMPILING_IN_CPYTHON
897
+ #if CYTHON_COMPILING_IN_CPYTHON
833
898
  static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
834
899
  PyObject *v;
835
900
  Py_ssize_t i;
@@ -838,34 +903,54 @@ static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRI
838
903
  Py_INCREF(v);
839
904
  }
840
905
  }
906
+ #endif
841
907
 
842
- static CYTHON_INLINE PyObject *
843
- __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
844
- {
845
- PyObject *res;
908
+ /////////////// TupleOrListFromArrayImpl.proto //////////////
909
+
910
+ {{if Type == 'Tuple'}}
911
+ #if PY_VERSION_HEX >= 0x030F0000 && !CYTHON_COMPILING_IN_LIMITED_API
912
+ #define __Pyx_PyTuple_FromArray(src, n) PyTuple_FromArray(src, ((n)<0) ? 0 : (n))
913
+ #else
914
+ {{endif}}
915
+ CYTHON_UNUSED static PyObject *
916
+ __Pyx_Py{{Type}}_FromArray(PyObject *const *src, Py_ssize_t n); /* proto */
917
+ {{if Type == 'Tuple'}}
918
+ #endif
919
+ {{endif}}
920
+
921
+ /////////////// TupleOrListFromArrayImpl //////////////
922
+ //@requires: CopyObjectArray
923
+
924
+ {{if Type == 'Tuple'}}
925
+ #if !(PY_VERSION_HEX >= 0x030F0000 && !CYTHON_COMPILING_IN_LIMITED_API)
926
+ {{endif}}
927
+ CYTHON_UNUSED static PyObject *
928
+ __Pyx_Py{{Type}}_FromArray(PyObject *const *src, Py_ssize_t n) {
929
+ {{if Type == 'Tuple'}}
846
930
  if (n <= 0) {
847
931
  return __Pyx_NewRef(EMPTY(tuple));
848
932
  }
849
- res = PyTuple_New(n);
850
- if (unlikely(res == NULL)) return NULL;
851
- __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n);
852
- return res;
853
- }
933
+ {{endif}}
854
934
 
855
- static CYTHON_INLINE PyObject *
856
- __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n)
857
- {
858
- PyObject *res;
859
- if (n <= 0) {
860
- return PyList_New(0);
861
- }
862
- res = PyList_New(n);
935
+ PyObject *res = Py{{Type}}_New(n);
863
936
  if (unlikely(res == NULL)) return NULL;
864
- __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n);
937
+ #if CYTHON_COMPILING_IN_CPYTHON
938
+ __Pyx_copy_object_array(src, ((Py{{Type}}Object*)res)->ob_item, n);
939
+ #else
940
+ Py_ssize_t i;
941
+ for (i = 0; i < n; i++) {
942
+ Py_INCREF(src[i]);
943
+ if (unlikely(__Pyx_Py{{Type}}_SET_ITEM(res, i, src[i]) < (0))) {
944
+ Py_DECREF(res);
945
+ return NULL;
946
+ }
947
+ }
948
+ #endif
865
949
  return res;
866
950
  }
951
+ {{if Type == 'Tuple'}}
867
952
  #endif
868
-
953
+ {{endif}}
869
954
 
870
955
  /////////////// SliceTupleAndList.proto ///////////////
871
956
 
@@ -878,7 +963,8 @@ static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t
878
963
  #endif
879
964
 
880
965
  /////////////// SliceTupleAndList ///////////////
881
- //@requires: TupleAndListFromArray
966
+ //@requires: ListFromArray
967
+ //@requires: TupleFromArray
882
968
  //@requires: Synchronization.c::CriticalSections
883
969
 
884
970
  #if CYTHON_COMPILING_IN_CPYTHON
@@ -1284,23 +1370,19 @@ static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObj
1284
1370
  static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
1285
1371
 
1286
1372
  /////////////// ExtTypeTest ///////////////
1373
+ //@requires: RaiseErrorWithObjectTypes
1287
1374
 
1288
1375
  static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
1289
- __Pyx_TypeName obj_type_name;
1290
- __Pyx_TypeName type_name;
1291
1376
  if (unlikely(!type)) {
1292
1377
  PyErr_SetString(PyExc_SystemError, "Missing type object");
1293
1378
  return 0;
1294
1379
  }
1295
1380
  if (likely(__Pyx_TypeCheck(obj, type)))
1296
1381
  return 1;
1297
- obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
1298
- type_name = __Pyx_PyType_GetFullyQualifiedName(type);
1299
- PyErr_Format(PyExc_TypeError,
1300
- "Cannot convert " __Pyx_FMT_TYPENAME " to " __Pyx_FMT_TYPENAME,
1301
- obj_type_name, type_name);
1302
- __Pyx_DECREF_TypeName(obj_type_name);
1303
- __Pyx_DECREF_TypeName(type_name);
1382
+
1383
+ __Pyx_RaiseTypeErrorWithTypes(
1384
+ "Cannot convert " __Pyx_FMT_TYPENAME " to " __Pyx_FMT_TYPENAME,
1385
+ Py_TYPE(obj), type);
1304
1386
  return 0;
1305
1387
  }
1306
1388
 
@@ -1388,6 +1470,7 @@ static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name); /*pro
1388
1470
 
1389
1471
  /////////////// GetNameInClass ///////////////
1390
1472
  //@requires: GetModuleGlobalName
1473
+ //@requires: Exceptions.c::IgnoreException
1391
1474
 
1392
1475
  static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name) {
1393
1476
  PyObject *result;
@@ -1406,7 +1489,9 @@ static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name) {
1406
1489
  return result;
1407
1490
  }
1408
1491
  }
1409
- PyErr_Clear();
1492
+ if (!__Pyx_IgnoreException(PyExc_Exception)) {
1493
+ return NULL; // BaseException
1494
+ }
1410
1495
  __Pyx_GetModuleGlobalNameUncached(result, name);
1411
1496
  return result;
1412
1497
  }
@@ -1490,6 +1575,7 @@ static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); /*pro
1490
1575
 
1491
1576
  /////////////// GetModuleGlobalName ///////////////
1492
1577
  //@requires: GetBuiltinName
1578
+ //@requires: Exceptions.c::IgnoreException
1493
1579
  //@substitute: naming
1494
1580
 
1495
1581
  #if CYTHON_USE_DICT_VERSIONS
@@ -1509,9 +1595,15 @@ static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
1509
1595
  if (likely(result)) {
1510
1596
  return result;
1511
1597
  }
1512
- PyErr_Clear();
1598
+ if (!__Pyx_IgnoreException(PyExc_Exception)) {
1599
+ return NULL; // BaseException
1600
+ }
1513
1601
  #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
1514
- if (unlikely(__Pyx_PyDict_GetItemRef(NAMED_CGLOBAL(moddict_cname), name, &result) == -1)) PyErr_Clear();
1602
+ if (unlikely(__Pyx_PyDict_GetItemRef(NAMED_CGLOBAL(moddict_cname), name, &result) == -1)) {
1603
+ if (!__Pyx_IgnoreException(PyExc_Exception)) {
1604
+ return NULL; // BaseException
1605
+ }
1606
+ }
1515
1607
  __PYX_UPDATE_DICT_CACHE(NAMED_CGLOBAL(moddict_cname), result, *dict_cached_value, *dict_version)
1516
1608
  if (likely(result)) {
1517
1609
  return result;
@@ -1523,7 +1615,10 @@ static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
1523
1615
  if (likely(result)) {
1524
1616
  return __Pyx_NewRef(result);
1525
1617
  }
1526
- PyErr_Clear();
1618
+ PyObject *exc = PyErr_Occurred();
1619
+ if (unlikely(exc) && !__Pyx_IgnoreGivenException(exc, PyExc_Exception)) {
1620
+ return NULL; // BaseException
1621
+ }
1527
1622
  #endif
1528
1623
  return __Pyx_GetBuiltinName(name);
1529
1624
  }
@@ -1675,103 +1770,16 @@ static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr
1675
1770
 
1676
1771
  /////////////// PyObjectGetMethod.proto ///////////////
1677
1772
 
1678
- #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
1773
+ #if !CYTHON_VECTORCALL
1679
1774
  static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);/*proto*/
1680
1775
  #endif
1681
1776
 
1682
1777
  /////////////// PyObjectGetMethod ///////////////
1683
1778
  //@requires: PyObjectGetAttrStr
1684
1779
 
1685
- #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
1780
+ #if !CYTHON_VECTORCALL
1686
1781
  static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
1687
- PyObject *attr;
1688
- #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
1689
- __Pyx_TypeName type_name;
1690
- // Copied from _PyObject_GetMethod() in CPython 3.7
1691
- PyTypeObject *tp = Py_TYPE(obj);
1692
- PyObject *descr;
1693
- descrgetfunc f = NULL;
1694
- PyObject **dictptr, *dict;
1695
- int meth_found = 0;
1696
-
1697
- assert (*method == NULL);
1698
-
1699
- if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
1700
- attr = __Pyx_PyObject_GetAttrStr(obj, name);
1701
- goto try_unpack;
1702
- }
1703
- if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
1704
- return 0;
1705
- }
1706
-
1707
- descr = _PyType_Lookup(tp, name);
1708
- if (likely(descr != NULL)) {
1709
- Py_INCREF(descr);
1710
- #if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR
1711
- if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR))
1712
- #else
1713
- // Repeating the condition below accommodates for MSVC's inability to test macros inside of macro expansions.
1714
- #ifdef __Pyx_CyFunction_USED
1715
- if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
1716
- #else
1717
- if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type)))
1718
- #endif
1719
- #endif
1720
- {
1721
- meth_found = 1;
1722
- } else {
1723
- f = Py_TYPE(descr)->tp_descr_get;
1724
- if (f != NULL && PyDescr_IsData(descr)) {
1725
- attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
1726
- Py_DECREF(descr);
1727
- goto try_unpack;
1728
- }
1729
- }
1730
- }
1731
-
1732
- dictptr = _PyObject_GetDictPtr(obj);
1733
- if (dictptr != NULL && (dict = *dictptr) != NULL) {
1734
- Py_INCREF(dict);
1735
- attr = __Pyx_PyDict_GetItemStr(dict, name);
1736
- if (attr != NULL) {
1737
- Py_INCREF(attr);
1738
- Py_DECREF(dict);
1739
- Py_XDECREF(descr);
1740
- goto try_unpack;
1741
- }
1742
- Py_DECREF(dict);
1743
- }
1744
-
1745
- if (meth_found) {
1746
- *method = descr;
1747
- return 1;
1748
- }
1749
-
1750
- if (f != NULL) {
1751
- attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
1752
- Py_DECREF(descr);
1753
- goto try_unpack;
1754
- }
1755
-
1756
- if (likely(descr != NULL)) {
1757
- *method = descr;
1758
- return 0;
1759
- }
1760
-
1761
- type_name = __Pyx_PyType_GetFullyQualifiedName(tp);
1762
- PyErr_Format(PyExc_AttributeError,
1763
- "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'",
1764
- type_name, name);
1765
- __Pyx_DECREF_TypeName(type_name);
1766
- return 0;
1767
-
1768
- // Generic fallback implementation using normal attribute lookup.
1769
- #else
1770
- attr = __Pyx_PyObject_GetAttrStr(obj, name);
1771
- goto try_unpack;
1772
- #endif
1773
-
1774
- try_unpack:
1782
+ PyObject *attr = __Pyx_PyObject_GetAttrStr(obj, name);
1775
1783
  #if CYTHON_UNPACK_METHODS
1776
1784
  // Even if we failed to avoid creating a bound method object, it's still worth unpacking it now, if possible.
1777
1785
  if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
@@ -1833,6 +1841,7 @@ static CYTHON_INLINE void __Pyx_CachedCFunction_SetFinishedInitializing(__Pyx_Ca
1833
1841
 
1834
1842
  /////////////// UnpackUnboundCMethod ///////////////
1835
1843
  //@requires: PyObjectGetAttrStr
1844
+ //@requires: Exceptions.c::IgnoreException
1836
1845
 
1837
1846
  #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000
1838
1847
  static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) {
@@ -1844,22 +1853,9 @@ static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *
1844
1853
  Py_DECREF(selfless_args);
1845
1854
  return result;
1846
1855
  }
1847
- #elif CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03090000
1848
- // PyPy 3.8 does not define 'args' as 'const'.
1849
- // See https://github.com/cython/cython/issues/6867
1850
- static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) {
1851
- return _PyObject_Vectorcall
1852
- (method, args ? args+1 : NULL, nargs ? nargs-1 : 0, kwnames);
1853
- }
1854
1856
  #else
1855
1857
  static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) {
1856
- return
1857
- #if PY_VERSION_HEX < 0x03090000
1858
- _PyObject_Vectorcall
1859
- #else
1860
- PyObject_Vectorcall
1861
- #endif
1862
- (method, args ? args+1 : NULL, nargs ? (size_t) nargs-1 : 0, kwnames);
1858
+ return PyObject_Vectorcall(method, args ? args+1 : NULL, nargs ? (size_t) nargs-1 : 0, kwnames);
1863
1859
  }
1864
1860
  #endif
1865
1861
 
@@ -1886,7 +1882,7 @@ static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
1886
1882
  {
1887
1883
  PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
1888
1884
  target->func = descr->d_method->ml_meth;
1889
- target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
1885
+ target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1890
1886
  } else
1891
1887
  #endif
1892
1888
  // bound classmethods need special treatment
@@ -1900,8 +1896,8 @@ static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
1900
1896
  int self_found;
1901
1897
  #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
1902
1898
  self = PyObject_GetAttrString(method, "__self__");
1903
- if (!self) {
1904
- PyErr_Clear();
1899
+ if (!self && !__Pyx_IgnoreException(PyExc_AttributeError)) {
1900
+ return -1;
1905
1901
  }
1906
1902
  #else
1907
1903
  self = PyCFunction_GET_SELF(method);
@@ -2148,13 +2144,13 @@ static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObje
2148
2144
  /////////////// PyObjectFastCall.proto ///////////////
2149
2145
 
2150
2146
  #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL)
2151
- static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs); /*proto*/
2147
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject * const*args, size_t nargsf, PyObject *kwargs); /*proto*/
2152
2148
 
2153
2149
  /////////////// PyObjectFastCall ///////////////
2154
2150
  //@requires: PyObjectCall
2155
2151
  //@requires: PyObjectCallMethO
2156
2152
 
2157
- #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API
2153
+ #if CYTHON_COMPILING_IN_LIMITED_API
2158
2154
  static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs) {
2159
2155
  PyObject *argstuple;
2160
2156
  PyObject *result = 0;
@@ -2173,10 +2169,8 @@ static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject * con
2173
2169
  }
2174
2170
  #endif
2175
2171
 
2176
- #if CYTHON_VECTORCALL && !CYTHON_COMPILING_IN_LIMITED_API
2177
- #if PY_VERSION_HEX < 0x03090000
2178
- #define __Pyx_PyVectorcall_Function(callable) _PyVectorcall_Function(callable)
2179
- #elif CYTHON_COMPILING_IN_CPYTHON
2172
+ #if CYTHON_VECTORCALL && !(CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY)
2173
+ #if CYTHON_COMPILING_IN_CPYTHON
2180
2174
  static CYTHON_INLINE vectorcallfunc __Pyx_PyVectorcall_Function(PyObject *callable) {
2181
2175
  PyTypeObject *tp = Py_TYPE(callable);
2182
2176
 
@@ -2203,12 +2197,12 @@ static CYTHON_INLINE vectorcallfunc __Pyx_PyVectorcall_Function(PyObject *callab
2203
2197
  #endif
2204
2198
  #endif
2205
2199
 
2206
- static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject *const *args, size_t _nargs, PyObject *kwargs) {
2200
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwargs) {
2207
2201
  // Special fast paths for 0 and 1 arguments
2208
2202
  // NOTE: in many cases, this is called with a constant value for nargs
2209
2203
  // which is known at compile-time. So the branches below will typically
2210
2204
  // be optimized away.
2211
- Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs);
2205
+ Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(nargsf);
2212
2206
  #if CYTHON_COMPILING_IN_CPYTHON
2213
2207
  if (nargs == 0 && kwargs == NULL) {
2214
2208
  if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS))
@@ -2222,12 +2216,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObj
2222
2216
 
2223
2217
  if (kwargs == NULL) {
2224
2218
  #if CYTHON_VECTORCALL
2225
- #if CYTHON_COMPILING_IN_LIMITED_API
2226
- return PyObject_Vectorcall(func, args, _nargs, NULL);
2219
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
2220
+ return PyObject_Vectorcall(func, args, nargsf, NULL);
2227
2221
  #else
2228
2222
  vectorcallfunc f = __Pyx_PyVectorcall_Function(func);
2229
2223
  if (f) {
2230
- return f(func, args, _nargs, NULL);
2224
+ return f(func, args, nargsf, NULL);
2231
2225
  }
2232
2226
  #endif
2233
2227
  #endif
@@ -2236,17 +2230,21 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObj
2236
2230
  if (nargs == 0) {
2237
2231
  return __Pyx_PyObject_Call(func, EMPTY(tuple), kwargs);
2238
2232
  }
2239
- #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API
2240
- return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs);
2241
- #else
2233
+
2234
+ #if CYTHON_COMPILING_IN_LIMITED_API
2242
2235
  return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs);
2236
+ #elif CYTHON_COMPILING_IN_PYPY
2237
+ // PyPy miscalculates nargs if we include PY_VECTORCALL_ARGUMENTS_OFFSET.
2238
+ return PyObject_VectorcallDict(func, args, (size_t) nargs, kwargs);
2239
+ #else
2240
+ return PyObject_VectorcallDict(func, args, nargsf, kwargs);
2243
2241
  #endif
2244
2242
  }
2245
2243
 
2246
2244
  /////////////// PyObjectFastCallMethod.proto ///////////////
2247
2245
  //@requires: PyObjectFastCall
2248
2246
 
2249
- #if CYTHON_VECTORCALL && PY_VERSION_HEX >= 0x03090000
2247
+ #if CYTHON_VECTORCALL
2250
2248
  #define __Pyx_PyObject_FastCallMethod(name, args, nargsf) PyObject_VectorcallMethod(name, args, nargsf, NULL)
2251
2249
  #else
2252
2250
  static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf); /* proto */
@@ -2254,9 +2252,22 @@ static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *
2254
2252
 
2255
2253
  /////////////// PyObjectFastCallMethod ///////////////
2256
2254
 
2257
- #if !CYTHON_VECTORCALL || PY_VERSION_HEX < 0x03090000
2255
+ #if !CYTHON_VECTORCALL
2258
2256
  static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf) {
2259
2257
  PyObject *result;
2258
+ switch (__Pyx_PyVectorcall_NARGS(nargsf)) {
2259
+ // no case 0 - there's always one positional argument.
2260
+ case 1:
2261
+ return PyObject_CallMethodObjArgs(args[0], name, NULL);
2262
+ case 2:
2263
+ return PyObject_CallMethodObjArgs(args[0], name, args[1], NULL);
2264
+ case 3:
2265
+ return PyObject_CallMethodObjArgs(args[0], name, args[1], args[2], NULL);
2266
+ case 4:
2267
+ return PyObject_CallMethodObjArgs(args[0], name, args[1], args[2], args[3], NULL);
2268
+ case 5:
2269
+ return PyObject_CallMethodObjArgs(args[0], name, args[1], args[2], args[3], args[4], NULL);
2270
+ }
2260
2271
  PyObject *attr = PyObject_GetAttr(args[0], name);
2261
2272
  if (unlikely(!attr))
2262
2273
  return NULL;
@@ -2266,87 +2277,78 @@ static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *
2266
2277
  }
2267
2278
  #endif
2268
2279
 
2269
- /////////////// PyObjectVectorCallKwBuilder.proto ////////////////
2280
+ /////////////// PyObjectVectorcallKwds.proto ////////////////////
2270
2281
  //@requires: PyObjectFastCall
2271
- // For versions that define PyObject_Vectorcall, use PyObject_Vectorcall and define functions to build a kwnames tuple and add arguments to args.
2272
- // For versions that don't, use __Pyx_PyObject_FastCallDict and functions to build a keyword dictionary
2273
-
2274
- CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); /* proto */
2275
2282
 
2276
2283
  #if CYTHON_VECTORCALL
2277
- #if PY_VERSION_HEX >= 0x03090000
2278
- #define __Pyx_Object_Vectorcall_CallFromBuilder PyObject_Vectorcall
2284
+ #define __Pyx_Object_VectorcallKwds PyObject_Vectorcall
2285
+ CYTHON_UNUSED static int __Pyx_CheckVectorcallKwarg(PyObject *kwnames, Py_ssize_t i); /* proto */
2279
2286
  #else
2280
- #define __Pyx_Object_Vectorcall_CallFromBuilder _PyObject_Vectorcall
2287
+ #define __Pyx_Object_VectorcallKwds __Pyx_PyObject_FastCallDict
2288
+ CYTHON_UNUSED static PyObject *__Pyx_MakeKwargDict(PyObject **keys, PyObject **values, Py_ssize_t n); /* proto */
2289
+ CYTHON_UNUSED static int __Pyx_CheckVectorcallKwarg(PyObject **kwnames, Py_ssize_t i); /* proto */
2281
2290
  #endif
2282
2291
 
2283
- #define __Pyx_MakeVectorcallBuilderKwds(n) PyTuple_New(n)
2284
-
2285
- static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); /* proto */
2286
- static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n); /* proto */
2287
- #else
2288
- #define __Pyx_Object_Vectorcall_CallFromBuilder __Pyx_PyObject_FastCallDict
2289
-
2290
- #define __Pyx_MakeVectorcallBuilderKwds(n) __Pyx_PyDict_NewPresized(n)
2291
-
2292
- #define __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n) PyDict_SetItem(builder, key, value)
2293
- #define __Pyx_VectorcallBuilder_AddArgStr(key, value, builder, args, n) PyDict_SetItemString(builder, key, value)
2294
- #endif
2295
-
2296
- /////////////// PyObjectVectorCallKwBuilder ////////////////
2292
+ /////////////// PyObjectVectorcallKwds ////////////////////
2297
2293
 
2298
2294
  #if CYTHON_VECTORCALL
2299
- static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
2300
- (void)__Pyx_PyObject_FastCallDict;
2301
-
2302
- Py_INCREF(key);
2303
- if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1;
2304
- args[n] = value;
2305
- return 0;
2306
- }
2295
+ CYTHON_UNUSED static int __Pyx_CheckVectorcallKwarg(PyObject *kwnames, Py_ssize_t i) {
2296
+ PyObject *key = __Pyx_PyTuple_GET_ITEM(kwnames, i);
2297
+ #if !CYTHON_ASSUME_SAFE_MACROS
2298
+ if (unlikely(!key)) return -1;
2299
+ #endif
2307
2300
 
2308
- CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
2309
- (void)__Pyx_VectorcallBuilder_AddArgStr;
2310
2301
  if (unlikely(!PyUnicode_Check(key))) {
2311
2302
  PyErr_SetString(PyExc_TypeError, "keywords must be strings");
2312
2303
  return -1;
2313
2304
  }
2314
- return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n);
2305
+ return 0;
2315
2306
  }
2316
2307
 
2317
- static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
2318
- PyObject *pyKey = PyUnicode_FromString(key);
2319
- if (!pyKey) return -1;
2320
- return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n);
2308
+ #else
2309
+
2310
+ CYTHON_UNUSED static PyObject *__Pyx_MakeKwargDict(PyObject **keys, PyObject **values, Py_ssize_t n) {
2311
+ PyObject *out = PyDict_New();
2312
+ if (unlikely(!out)) return NULL;
2313
+ for (Py_ssize_t i=0; i<n; ++i) {
2314
+ if (unlikely(PyDict_SetItem(out, keys[i], values[i]) < 0)) {
2315
+ Py_DECREF(out);
2316
+ return NULL;
2317
+ }
2318
+ }
2319
+ return out;
2321
2320
  }
2322
- #else // CYTHON_VECTORCALL
2323
- CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) {
2321
+
2322
+ CYTHON_UNUSED static int __Pyx_CheckVectorcallKwarg(PyObject **kwnames, Py_ssize_t i) {
2323
+ PyObject *key = kwnames[i];
2324
+
2324
2325
  if (unlikely(!PyUnicode_Check(key))) {
2325
2326
  PyErr_SetString(PyExc_TypeError, "keywords must be strings");
2326
2327
  return -1;
2327
2328
  }
2328
- return PyDict_SetItem(builder, key, value);
2329
+ return 0;
2329
2330
  }
2331
+
2330
2332
  #endif
2331
2333
 
2332
- /////////////// PyObjectVectorCallMethodKwBuilder.proto ////////////////
2334
+ /////////////// PyObjectVectorcallMethodKwds.proto /////////////////
2335
+ //@requires: PyObjectVectorcallKwds
2333
2336
 
2334
- #if CYTHON_VECTORCALL && PY_VERSION_HEX >= 0x03090000
2335
- #define __Pyx_Object_VectorcallMethod_CallFromBuilder PyObject_VectorcallMethod
2337
+ #if CYTHON_VECTORCALL
2338
+ #define __Pyx_Object_VectorcallMethodKwds PyObject_VectorcallMethod
2336
2339
  #else
2337
- static PyObject *__Pyx_Object_VectorcallMethod_CallFromBuilder(PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames); /* proto */
2340
+ static PyObject *__Pyx_Object_VectorcallMethodKwds(PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames); /* proto */
2338
2341
  #endif
2339
2342
 
2340
- /////////////// PyObjectVectorCallMethodKwBuilder ////////////////
2341
- //@requires: PyObjectVectorCallKwBuilder
2343
+ /////////////// PyObjectVectorcallMethodKwds ///////////////////
2342
2344
 
2343
- #if !CYTHON_VECTORCALL || PY_VERSION_HEX < 0x03090000
2344
- static PyObject *__Pyx_Object_VectorcallMethod_CallFromBuilder(PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames) {
2345
+ #if !CYTHON_VECTORCALL
2346
+ static PyObject *__Pyx_Object_VectorcallMethodKwds(PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames) {
2345
2347
  PyObject *result;
2346
2348
  PyObject *obj = PyObject_GetAttr(args[0], name);
2347
2349
  if (unlikely(!obj))
2348
2350
  return NULL;
2349
- result = __Pyx_Object_Vectorcall_CallFromBuilder(obj, args+1, nargsf-1, kwnames);
2351
+ result = __Pyx_Object_VectorcallKwds(obj, args+1, nargsf-1, kwnames);
2350
2352
  Py_DECREF(obj);
2351
2353
  return result;
2352
2354
  }
@@ -2362,7 +2364,7 @@ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name
2362
2364
  //@requires: PyObjectCallNoArg
2363
2365
 
2364
2366
  static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
2365
- #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))
2367
+ #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || !CYTHON_COMPILING_IN_LIMITED_API)
2366
2368
  PyObject *args[1] = {obj};
2367
2369
  // avoid unused functions
2368
2370
  (void) __Pyx_PyObject_CallOneArg;
@@ -2394,7 +2396,7 @@ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name
2394
2396
  //@requires: PyObjectCallOneArg
2395
2397
  //@requires: PyObjectCall2Args
2396
2398
 
2397
- #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
2399
+ #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || !CYTHON_COMPILING_IN_LIMITED_API))
2398
2400
  static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
2399
2401
  // Separate function to avoid excessive inlining.
2400
2402
  PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
@@ -2404,7 +2406,7 @@ static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
2404
2406
  #endif
2405
2407
 
2406
2408
  static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
2407
- #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))
2409
+ #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || !CYTHON_COMPILING_IN_LIMITED_API)
2408
2410
  PyObject *args[2] = {obj, arg};
2409
2411
  // avoid unused functions
2410
2412
  (void) __Pyx_PyObject_CallOneArg;
@@ -2572,14 +2574,14 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
2572
2574
 
2573
2575
  /////////////// PyVectorcallFastCallDict.proto ///////////////
2574
2576
 
2575
- #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
2577
+ #if CYTHON_VECTORCALL
2576
2578
  static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw);
2577
2579
  #endif
2578
2580
 
2579
2581
  /////////////// PyVectorcallFastCallDict ///////////////
2580
2582
  //@requires: OwnedDictNext
2581
2583
 
2582
- #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
2584
+ #if CYTHON_VECTORCALL
2583
2585
  // Slow path when kw is non-empty
2584
2586
  static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
2585
2587
  {
@@ -3014,18 +3016,124 @@ static CYTHON_INLINE PyObject* __Pyx_{{typeobj}}_Multiply(PyObject *seq, Py_ssiz
3014
3016
  return slot(seq, mul);
3015
3017
  }
3016
3018
 
3017
- /////////////// FormatTypeName.proto ///////////////
3018
3019
 
3020
+ /////////////// RaiseErrorWithObjectType.proto ///////////////
3021
+
3022
+ #define __Pyx_RaiseTypeErrorWithObjectType(message, obj) __Pyx_RaiseErrorWithObjectType(PyExc_TypeError, message, obj)
3023
+ #define __Pyx_RaiseErrorWithObjectType(exc_type, message, obj) __Pyx_RaiseErrorWithType(exc_type, message, Py_TYPE(obj))
3024
+
3025
+ CYTHON_UNUSED
3026
+ static void __Pyx_RaiseErrorWithType(PyObject* exc_type, const char* message, PyTypeObject *type_obj); /*proto*/
3027
+
3028
+ /////////////// RaiseErrorWithObjectType ///////////////
3029
+ //@requires: FormatTypeName
3030
+
3031
+ static void __Pyx_RaiseErrorWithType(PyObject* exc_type, const char* message, PyTypeObject *type_obj) {
3032
+ __Pyx_TypeName type_name = __Pyx_PyType_GetFullyQualifiedName(type_obj);
3033
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
3034
+ if (unlikely(!type_name)) return;
3035
+ #endif
3036
+ PyErr_Format(exc_type, message, type_name);
3037
+ __Pyx_DECREF_TypeName(type_name);
3038
+ }
3039
+
3040
+
3041
+ /////////////// RaiseErrorWithObjectType1.proto ///////////////
3042
+
3043
+ #define __Pyx_RaiseTypeErrorWithObjectType1(message, arg, obj) __Pyx_RaiseErrorWithObjectType1(PyExc_TypeError, message, arg, obj)
3044
+ #define __Pyx_RaiseErrorWithObjectType1(exc_type, message, arg, obj) __Pyx_RaiseErrorWithType1(exc_type, message, arg, Py_TYPE(obj))
3045
+
3046
+ CYTHON_UNUSED
3047
+ static void __Pyx_RaiseErrorWithType1(PyObject* exc_type, const char* message, const char *arg, PyTypeObject *type_obj); /*proto*/
3048
+
3049
+ /////////////// RaiseErrorWithObjectType1 ///////////////
3050
+ //@requires: FormatTypeName
3051
+
3052
+ static void __Pyx_RaiseErrorWithType1(PyObject* exc_type, const char* message, const char *arg, PyTypeObject *type_obj) {
3053
+ __Pyx_TypeName type_name = __Pyx_PyType_GetFullyQualifiedName(type_obj);
3054
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
3055
+ if (unlikely(!type_name)) return;
3056
+ #endif
3057
+ PyErr_Format(exc_type, message, arg, type_name);
3058
+ __Pyx_DECREF_TypeName(type_name);
3059
+ }
3060
+
3061
+ ///////////// RaiseErrorWithTypeAndVarargs.proto ///////////////////////
3062
+ //@requires: FormatTypeName
3063
+
3064
+ // The first argument of the variadic arguments must be the type name
3065
+ #define __Pyx_RaiseErrorWithTypeAndVarargs(exc_type, message, type_obj, ...) \
3066
+ __Pyx__RaiseErrorWithTypeAndVarargs(exc_type, message, __Pyx_PyType_GetFullyQualifiedName(type_obj), __VA_ARGS__)
3067
+
3068
+ static void __Pyx__RaiseErrorWithTypeAndVarargs(PyObject* exc_type, const char* message, ...); /* proto */
3069
+
3070
+ ///////////// RaiseErrorWithTypeAndVarargs ///////////////////////
3071
+
3072
+ static void __Pyx__RaiseErrorWithTypeAndVarargs(PyObject* exc_type, const char* message, ...)
3073
+ {
3074
+ va_list arg_list;
3019
3075
  #if CYTHON_COMPILING_IN_LIMITED_API
3076
+ va_start(arg_list, message);
3077
+ __Pyx_TypeName tp_name = va_arg(arg_list, __Pyx_TypeName);
3078
+ va_end(arg_list);
3079
+ #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
3080
+ if (!tp_name) return;
3081
+ #endif
3082
+ #endif
3083
+ va_start(arg_list, message);
3084
+ PyErr_FormatV(exc_type, message, arg_list);
3085
+ va_end(arg_list);
3086
+ __Pyx_DECREF_TypeName(tp_name); // No-op outside Limited API so doesn't matter that it's undefined.
3087
+ }
3088
+
3089
+ /////////////// RaiseErrorWithObjectTypes.proto ///////////////
3090
+
3091
+ #define __Pyx_RaiseErrorWithObjectTypes1(exc_type, message, arg, obj1, obj2) __Pyx_RaiseErrorWithTypes1(exc_type, message, arg, Py_TYPE(obj1), Py_TYPE(obj2))
3092
+ #define __Pyx_RaiseTypeErrorWithTypes(message, type_obj1, type_obj2) __Pyx_RaiseErrorWithTypes1(PyExc_TypeError, "%s" message, "", type_obj1, type_obj2)
3093
+
3094
+ CYTHON_UNUSED
3095
+ static void __Pyx_RaiseErrorWithTypes1(PyObject* exc_type, const char *message, const char *arg, PyTypeObject *type_obj1, PyTypeObject *type_obj2); /*proto*/
3096
+
3097
+ /////////////// RaiseErrorWithObjectTypes ///////////////
3098
+ //@requires: FormatTypeName
3099
+
3100
+ static void __Pyx_RaiseErrorWithTypes1(PyObject* exc_type, const char *message, const char *arg, PyTypeObject *type_obj1, PyTypeObject *type_obj2) {
3101
+ __Pyx_TypeName type_name1 = __Pyx_PyType_GetFullyQualifiedName(type_obj1);
3102
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
3103
+ if (unlikely(!type_name1)) return;
3104
+ #endif
3105
+ __Pyx_TypeName type_name2 = __Pyx_PyType_GetFullyQualifiedName(type_obj2);
3106
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
3107
+ if (unlikely(!type_name2)) goto type2_failed;
3108
+ #endif
3109
+
3110
+ PyErr_Format(exc_type, message, arg, type_name1, type_name2);
3111
+
3112
+ __Pyx_DECREF_TypeName(type_name2);
3113
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
3114
+ type2_failed:
3115
+ #endif
3116
+ __Pyx_DECREF_TypeName(type_name1);
3117
+ }
3118
+
3119
+
3120
+ /////////////// FormatTypeName.proto ///////////////
3121
+
3122
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX >= 0x030d0000
3123
+ // For these versions we can just pass the type, use the %N format code and
3124
+ // Python handles the whole thing internally.
3125
+ typedef PyObject *__Pyx_TypeName;
3126
+ #define __Pyx_FMT_TYPENAME "%N"
3127
+ #define __Pyx_PyType_GetFullyQualifiedName(tp) Py_NewRef((PyObject*)tp)
3128
+ #define __Pyx_DECREF_TypeName(obj) Py_DECREF(obj)
3129
+
3130
+ #elif CYTHON_COMPILING_IN_LIMITED_API
3020
3131
  typedef PyObject *__Pyx_TypeName;
3021
3132
  #define __Pyx_FMT_TYPENAME "%U"
3022
3133
  #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj)
3023
3134
 
3024
- #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
3025
- #define __Pyx_PyType_GetFullyQualifiedName PyType_GetFullyQualifiedName
3026
- #else
3027
3135
  static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp); /*proto*/
3028
- #endif
3136
+
3029
3137
  #else // !LIMITED_API
3030
3138
  typedef const char *__Pyx_TypeName;
3031
3139
  #define __Pyx_FMT_TYPENAME "%.200s"
@@ -3085,14 +3193,12 @@ __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp)
3085
3193
  static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj); /*proto*/
3086
3194
 
3087
3195
  /////////////// RaiseUnexpectedTypeError ///////////////
3196
+ //@requires: RaiseErrorWithObjectType1
3088
3197
 
3089
- static int
3090
- __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj)
3091
- {
3092
- __Pyx_TypeName obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
3093
- PyErr_Format(PyExc_TypeError, "Expected %s, got " __Pyx_FMT_TYPENAME,
3094
- expected, obj_type_name);
3095
- __Pyx_DECREF_TypeName(obj_type_name);
3198
+ static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj) {
3199
+ __Pyx_RaiseTypeErrorWithObjectType1(
3200
+ "Expected %s, got " __Pyx_FMT_TYPENAME,
3201
+ expected, obj);
3096
3202
  return 0;
3097
3203
  }
3098
3204
 
@@ -3179,33 +3285,6 @@ static void __Pyx_RaiseCppAttributeErrorNogil(const char *varname) {
3179
3285
  PyGILState_Release(gilstate);
3180
3286
  }
3181
3287
 
3182
- /////////////// ListPack.proto //////////////////////////////////////
3183
-
3184
- // Equivalent to PyTuple_Pack for sections where we want to reduce the code size
3185
- static PyObject *__Pyx_PyList_Pack(Py_ssize_t n, ...); /* proto */
3186
-
3187
- /////////////// ListPack //////////////////////////////////////
3188
-
3189
- static PyObject *__Pyx_PyList_Pack(Py_ssize_t n, ...) {
3190
- va_list va;
3191
- PyObject *l = PyList_New(n);
3192
- va_start(va, n);
3193
- if (unlikely(!l)) goto end;
3194
-
3195
- for (Py_ssize_t i=0; i<n; ++i) {
3196
- PyObject *arg = va_arg(va, PyObject*);
3197
- Py_INCREF(arg);
3198
- if (__Pyx_PyList_SET_ITEM(l, i, arg) != (0)) {
3199
- Py_CLEAR(l);
3200
- goto end;
3201
- }
3202
- }
3203
-
3204
- end:
3205
- va_end(va);
3206
- return l;
3207
- }
3208
-
3209
3288
  /////////////// LengthHint.proto //////////////////////////////////////
3210
3289
 
3211
3290
  #if CYTHON_COMPILING_IN_LIMITED_API