cytriangle 1.0.2__cp310-cp310-win_amd64.whl → 1.0.3__cp310-cp310-win_amd64.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 cytriangle might be problematic. Click here for more details.

cytriangle/cytriangleio.c CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated by Cython 3.0.10 */
1
+ /* Generated by Cython 3.0.11 */
2
2
 
3
3
  /* BEGIN: Cython Metadata
4
4
  {
@@ -61,10 +61,10 @@ END: Cython Metadata */
61
61
  #else
62
62
  #define __PYX_EXTRA_ABI_MODULE_NAME ""
63
63
  #endif
64
- #define CYTHON_ABI "3_0_10" __PYX_EXTRA_ABI_MODULE_NAME
64
+ #define CYTHON_ABI "3_0_11" __PYX_EXTRA_ABI_MODULE_NAME
65
65
  #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI
66
66
  #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."
67
- #define CYTHON_HEX_VERSION 0x03000AF0
67
+ #define CYTHON_HEX_VERSION 0x03000BF0
68
68
  #define CYTHON_FUTURE_DIVISION 1
69
69
  #include <stddef.h>
70
70
  #ifndef offsetof
@@ -4291,7 +4291,7 @@ static int __pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_4__init__(struct __
4291
4291
  PyObject *__pyx_t_3 = NULL;
4292
4292
  PyObject *__pyx_t_4 = NULL;
4293
4293
  PyObject *__pyx_t_5 = NULL;
4294
- int __pyx_t_6;
4294
+ unsigned int __pyx_t_6;
4295
4295
  Py_ssize_t __pyx_t_7;
4296
4296
  int __pyx_lineno = 0;
4297
4297
  const char *__pyx_filename = NULL;
@@ -5239,7 +5239,7 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_6to_dict(stru
5239
5239
  PyObject *__pyx_t_3 = NULL;
5240
5240
  PyObject *__pyx_t_4 = NULL;
5241
5241
  PyObject *__pyx_t_5 = NULL;
5242
- int __pyx_t_6;
5242
+ unsigned int __pyx_t_6;
5243
5243
  int __pyx_lineno = 0;
5244
5244
  const char *__pyx_filename = NULL;
5245
5245
  int __pyx_clineno = 0;
@@ -6280,7 +6280,7 @@ static int __pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_8vertices_2__set__(
6280
6280
  PyObject *__pyx_t_1 = NULL;
6281
6281
  PyObject *__pyx_t_2 = NULL;
6282
6282
  PyObject *__pyx_t_3 = NULL;
6283
- int __pyx_t_4;
6283
+ unsigned int __pyx_t_4;
6284
6284
  int __pyx_lineno = 0;
6285
6285
  const char *__pyx_filename = NULL;
6286
6286
  int __pyx_clineno = 0;
@@ -6702,7 +6702,7 @@ static int __pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_17vertex_attributes
6702
6702
  PyObject *__pyx_t_1 = NULL;
6703
6703
  PyObject *__pyx_t_2 = NULL;
6704
6704
  PyObject *__pyx_t_3 = NULL;
6705
- int __pyx_t_4;
6705
+ unsigned int __pyx_t_4;
6706
6706
  int __pyx_lineno = 0;
6707
6707
  const char *__pyx_filename = NULL;
6708
6708
  int __pyx_clineno = 0;
@@ -6896,7 +6896,7 @@ static int __pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_14vertex_markers_2_
6896
6896
  PyObject *__pyx_t_1 = NULL;
6897
6897
  PyObject *__pyx_t_2 = NULL;
6898
6898
  PyObject *__pyx_t_3 = NULL;
6899
- int __pyx_t_4;
6899
+ unsigned int __pyx_t_4;
6900
6900
  int __pyx_lineno = 0;
6901
6901
  const char *__pyx_filename = NULL;
6902
6902
  int __pyx_clineno = 0;
@@ -7310,7 +7310,7 @@ static int __pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_9triangles_2__set__
7310
7310
  PyObject *__pyx_t_1 = NULL;
7311
7311
  PyObject *__pyx_t_2 = NULL;
7312
7312
  PyObject *__pyx_t_3 = NULL;
7313
- int __pyx_t_4;
7313
+ unsigned int __pyx_t_4;
7314
7314
  int __pyx_lineno = 0;
7315
7315
  const char *__pyx_filename = NULL;
7316
7316
  int __pyx_clineno = 0;
@@ -7732,7 +7732,7 @@ static int __pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_19triangle_attribut
7732
7732
  PyObject *__pyx_t_1 = NULL;
7733
7733
  PyObject *__pyx_t_2 = NULL;
7734
7734
  PyObject *__pyx_t_3 = NULL;
7735
- int __pyx_t_4;
7735
+ unsigned int __pyx_t_4;
7736
7736
  int __pyx_lineno = 0;
7737
7737
  const char *__pyx_filename = NULL;
7738
7738
  int __pyx_clineno = 0;
@@ -7942,7 +7942,7 @@ static int __pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_17triangle_max_area
7942
7942
  PyObject *__pyx_t_1 = NULL;
7943
7943
  PyObject *__pyx_t_2 = NULL;
7944
7944
  PyObject *__pyx_t_3 = NULL;
7945
- int __pyx_t_4;
7945
+ unsigned int __pyx_t_4;
7946
7946
  int __pyx_lineno = 0;
7947
7947
  const char *__pyx_filename = NULL;
7948
7948
  int __pyx_clineno = 0;
@@ -8654,7 +8654,7 @@ static int __pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_8segments_2__set__(
8654
8654
  PyObject *__pyx_t_1 = NULL;
8655
8655
  PyObject *__pyx_t_2 = NULL;
8656
8656
  PyObject *__pyx_t_3 = NULL;
8657
- int __pyx_t_4;
8657
+ unsigned int __pyx_t_4;
8658
8658
  int __pyx_lineno = 0;
8659
8659
  const char *__pyx_filename = NULL;
8660
8660
  int __pyx_clineno = 0;
@@ -8878,7 +8878,7 @@ static int __pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_5holes_2__set__(str
8878
8878
  PyObject *__pyx_t_1 = NULL;
8879
8879
  PyObject *__pyx_t_2 = NULL;
8880
8880
  PyObject *__pyx_t_3 = NULL;
8881
- int __pyx_t_4;
8881
+ unsigned int __pyx_t_4;
8882
8882
  int __pyx_lineno = 0;
8883
8883
  const char *__pyx_filename = NULL;
8884
8884
  int __pyx_clineno = 0;
@@ -9097,7 +9097,7 @@ static int __pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_15segment_markers_2
9097
9097
  PyObject *__pyx_t_1 = NULL;
9098
9098
  PyObject *__pyx_t_2 = NULL;
9099
9099
  PyObject *__pyx_t_3 = NULL;
9100
- int __pyx_t_4;
9100
+ unsigned int __pyx_t_4;
9101
9101
  int __pyx_lineno = 0;
9102
9102
  const char *__pyx_filename = NULL;
9103
9103
  int __pyx_clineno = 0;
@@ -9486,7 +9486,7 @@ static int __pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_7regions_2__set__(s
9486
9486
  PyObject *__pyx_t_1 = NULL;
9487
9487
  PyObject *__pyx_t_2 = NULL;
9488
9488
  PyObject *__pyx_t_3 = NULL;
9489
- int __pyx_t_4;
9489
+ unsigned int __pyx_t_4;
9490
9490
  int __pyx_lineno = 0;
9491
9491
  const char *__pyx_filename = NULL;
9492
9492
  int __pyx_clineno = 0;
@@ -10292,10 +10292,11 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_8set_vertices
10292
10292
  int __pyx_t_4;
10293
10293
  PyObject *__pyx_t_5 = NULL;
10294
10294
  PyObject *__pyx_t_6 = NULL;
10295
- size_t __pyx_t_7;
10296
- PyObject *(*__pyx_t_8)(PyObject *);
10297
- double __pyx_t_9;
10298
- Py_ssize_t __pyx_t_10;
10295
+ unsigned int __pyx_t_7;
10296
+ size_t __pyx_t_8;
10297
+ PyObject *(*__pyx_t_9)(PyObject *);
10298
+ double __pyx_t_10;
10299
+ Py_ssize_t __pyx_t_11;
10299
10300
  int __pyx_lineno = 0;
10300
10301
  const char *__pyx_filename = NULL;
10301
10302
  int __pyx_clineno = 0;
@@ -10372,7 +10373,7 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_8set_vertices
10372
10373
  __Pyx_GOTREF(__pyx_t_6);
10373
10374
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10374
10375
  __pyx_t_5 = NULL;
10375
- __pyx_t_3 = 0;
10376
+ __pyx_t_7 = 0;
10376
10377
  #if CYTHON_UNPACK_METHODS
10377
10378
  if (unlikely(PyMethod_Check(__pyx_t_6))) {
10378
10379
  __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
@@ -10381,13 +10382,13 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_8set_vertices
10381
10382
  __Pyx_INCREF(__pyx_t_5);
10382
10383
  __Pyx_INCREF(function);
10383
10384
  __Pyx_DECREF_SET(__pyx_t_6, function);
10384
- __pyx_t_3 = 1;
10385
+ __pyx_t_7 = 1;
10385
10386
  }
10386
10387
  }
10387
10388
  #endif
10388
10389
  {
10389
10390
  PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_vertices};
10390
- __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_3, 1+__pyx_t_3);
10391
+ __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7);
10391
10392
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
10392
10393
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 467, __pyx_L1_error)
10393
10394
  __Pyx_GOTREF(__pyx_t_2);
@@ -10411,9 +10412,9 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_8set_vertices
10411
10412
  __Pyx_GOTREF(__pyx_t_5);
10412
10413
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10413
10414
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10414
- __pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 468, __pyx_L1_error)
10415
+ __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 468, __pyx_L1_error)
10415
10416
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10416
- __pyx_v_self->_io->pointlist = ((double *)malloc(__pyx_t_7));
10417
+ __pyx_v_self->_io->pointlist = ((double *)malloc(__pyx_t_8));
10417
10418
 
10418
10419
  /* "cytriangle/cytriangleio.pyx":469
10419
10420
  * vertices = np.ascontiguousarray(vertices)
@@ -10427,15 +10428,15 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_8set_vertices
10427
10428
  if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
10428
10429
  __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6);
10429
10430
  __pyx_t_1 = 0;
10430
- __pyx_t_8 = NULL;
10431
+ __pyx_t_9 = NULL;
10431
10432
  } else {
10432
10433
  __pyx_t_1 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L1_error)
10433
10434
  __Pyx_GOTREF(__pyx_t_6);
10434
- __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 469, __pyx_L1_error)
10435
+ __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 469, __pyx_L1_error)
10435
10436
  }
10436
10437
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10437
10438
  for (;;) {
10438
- if (likely(!__pyx_t_8)) {
10439
+ if (likely(!__pyx_t_9)) {
10439
10440
  if (likely(PyList_CheckExact(__pyx_t_6))) {
10440
10441
  {
10441
10442
  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
@@ -10466,7 +10467,7 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_8set_vertices
10466
10467
  #endif
10467
10468
  }
10468
10469
  } else {
10469
- __pyx_t_5 = __pyx_t_8(__pyx_t_6);
10470
+ __pyx_t_5 = __pyx_t_9(__pyx_t_6);
10470
10471
  if (unlikely(!__pyx_t_5)) {
10471
10472
  PyObject* exc_type = PyErr_Occurred();
10472
10473
  if (exc_type) {
@@ -10498,13 +10499,13 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_8set_vertices
10498
10499
  __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_vertices, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 470, __pyx_L1_error)
10499
10500
  __Pyx_GOTREF(__pyx_t_2);
10500
10501
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10501
- __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 470, __pyx_L1_error)
10502
+ __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 470, __pyx_L1_error)
10502
10503
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10503
10504
  __pyx_t_2 = __Pyx_PyInt_MultiplyCObj(__pyx_int_2, __pyx_v_i, 2, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 470, __pyx_L1_error)
10504
10505
  __Pyx_GOTREF(__pyx_t_2);
10505
- __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 470, __pyx_L1_error)
10506
+ __pyx_t_11 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_11 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 470, __pyx_L1_error)
10506
10507
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10507
- (__pyx_v_self->_io->pointlist[__pyx_t_10]) = __pyx_t_9;
10508
+ (__pyx_v_self->_io->pointlist[__pyx_t_11]) = __pyx_t_10;
10508
10509
 
10509
10510
  /* "cytriangle/cytriangleio.pyx":471
10510
10511
  * for i in range(num_vertices):
@@ -10524,16 +10525,16 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_8set_vertices
10524
10525
  __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_vertices, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 471, __pyx_L1_error)
10525
10526
  __Pyx_GOTREF(__pyx_t_5);
10526
10527
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10527
- __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 471, __pyx_L1_error)
10528
+ __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 471, __pyx_L1_error)
10528
10529
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10529
10530
  __pyx_t_5 = __Pyx_PyInt_MultiplyCObj(__pyx_int_2, __pyx_v_i, 2, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 471, __pyx_L1_error)
10530
10531
  __Pyx_GOTREF(__pyx_t_5);
10531
10532
  __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_5, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error)
10532
10533
  __Pyx_GOTREF(__pyx_t_2);
10533
10534
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10534
- __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 471, __pyx_L1_error)
10535
+ __pyx_t_11 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_11 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 471, __pyx_L1_error)
10535
10536
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10536
- (__pyx_v_self->_io->pointlist[__pyx_t_10]) = __pyx_t_9;
10537
+ (__pyx_v_self->_io->pointlist[__pyx_t_11]) = __pyx_t_10;
10537
10538
 
10538
10539
  /* "cytriangle/cytriangleio.pyx":469
10539
10540
  * vertices = np.ascontiguousarray(vertices)
@@ -10685,15 +10686,16 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_10set_vertex_
10685
10686
  PyObject *__pyx_t_1 = NULL;
10686
10687
  PyObject *__pyx_t_2 = NULL;
10687
10688
  PyObject *__pyx_t_3 = NULL;
10688
- int __pyx_t_4;
10689
+ unsigned int __pyx_t_4;
10689
10690
  size_t __pyx_t_5;
10690
- Py_ssize_t __pyx_t_6;
10691
- PyObject *(*__pyx_t_7)(PyObject *);
10692
- Py_ssize_t __pyx_t_8;
10693
- PyObject *(*__pyx_t_9)(PyObject *);
10694
- PyObject *__pyx_t_10 = NULL;
10695
- double __pyx_t_11;
10696
- Py_ssize_t __pyx_t_12;
10691
+ int __pyx_t_6;
10692
+ Py_ssize_t __pyx_t_7;
10693
+ PyObject *(*__pyx_t_8)(PyObject *);
10694
+ Py_ssize_t __pyx_t_9;
10695
+ PyObject *(*__pyx_t_10)(PyObject *);
10696
+ PyObject *__pyx_t_11 = NULL;
10697
+ double __pyx_t_12;
10698
+ Py_ssize_t __pyx_t_13;
10697
10699
  int __pyx_lineno = 0;
10698
10700
  const char *__pyx_filename = NULL;
10699
10701
  int __pyx_clineno = 0;
@@ -10850,8 +10852,8 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_10set_vertex_
10850
10852
  * for i in range(num_vertices):
10851
10853
  * for j in range(num_attr):
10852
10854
  */
10853
- __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_num_attr); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 480, __pyx_L1_error)
10854
- __pyx_v_self->_io->numberofpointattributes = __pyx_t_4;
10855
+ __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_num_attr); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 480, __pyx_L1_error)
10856
+ __pyx_v_self->_io->numberofpointattributes = __pyx_t_6;
10855
10857
 
10856
10858
  /* "cytriangle/cytriangleio.pyx":481
10857
10859
  * num_attr * num_vertices * sizeof(double))
@@ -10864,28 +10866,28 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_10set_vertex_
10864
10866
  __Pyx_GOTREF(__pyx_t_2);
10865
10867
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
10866
10868
  __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3);
10867
- __pyx_t_6 = 0;
10868
- __pyx_t_7 = NULL;
10869
+ __pyx_t_7 = 0;
10870
+ __pyx_t_8 = NULL;
10869
10871
  } else {
10870
- __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 481, __pyx_L1_error)
10872
+ __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 481, __pyx_L1_error)
10871
10873
  __Pyx_GOTREF(__pyx_t_3);
10872
- __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 481, __pyx_L1_error)
10874
+ __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 481, __pyx_L1_error)
10873
10875
  }
10874
10876
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10875
10877
  for (;;) {
10876
- if (likely(!__pyx_t_7)) {
10878
+ if (likely(!__pyx_t_8)) {
10877
10879
  if (likely(PyList_CheckExact(__pyx_t_3))) {
10878
10880
  {
10879
10881
  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3);
10880
10882
  #if !CYTHON_ASSUME_SAFE_MACROS
10881
10883
  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 481, __pyx_L1_error)
10882
10884
  #endif
10883
- if (__pyx_t_6 >= __pyx_temp) break;
10885
+ if (__pyx_t_7 >= __pyx_temp) break;
10884
10886
  }
10885
10887
  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10886
- __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 481, __pyx_L1_error)
10888
+ __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 481, __pyx_L1_error)
10887
10889
  #else
10888
- __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 481, __pyx_L1_error)
10890
+ __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 481, __pyx_L1_error)
10889
10891
  __Pyx_GOTREF(__pyx_t_2);
10890
10892
  #endif
10891
10893
  } else {
@@ -10894,17 +10896,17 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_10set_vertex_
10894
10896
  #if !CYTHON_ASSUME_SAFE_MACROS
10895
10897
  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 481, __pyx_L1_error)
10896
10898
  #endif
10897
- if (__pyx_t_6 >= __pyx_temp) break;
10899
+ if (__pyx_t_7 >= __pyx_temp) break;
10898
10900
  }
10899
10901
  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10900
- __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 481, __pyx_L1_error)
10902
+ __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 481, __pyx_L1_error)
10901
10903
  #else
10902
- __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 481, __pyx_L1_error)
10904
+ __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 481, __pyx_L1_error)
10903
10905
  __Pyx_GOTREF(__pyx_t_2);
10904
10906
  #endif
10905
10907
  }
10906
10908
  } else {
10907
- __pyx_t_2 = __pyx_t_7(__pyx_t_3);
10909
+ __pyx_t_2 = __pyx_t_8(__pyx_t_3);
10908
10910
  if (unlikely(!__pyx_t_2)) {
10909
10911
  PyObject* exc_type = PyErr_Occurred();
10910
10912
  if (exc_type) {
@@ -10929,28 +10931,28 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_10set_vertex_
10929
10931
  __Pyx_GOTREF(__pyx_t_2);
10930
10932
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
10931
10933
  __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1);
10932
- __pyx_t_8 = 0;
10933
- __pyx_t_9 = NULL;
10934
+ __pyx_t_9 = 0;
10935
+ __pyx_t_10 = NULL;
10934
10936
  } else {
10935
- __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 482, __pyx_L1_error)
10937
+ __pyx_t_9 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 482, __pyx_L1_error)
10936
10938
  __Pyx_GOTREF(__pyx_t_1);
10937
- __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 482, __pyx_L1_error)
10939
+ __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 482, __pyx_L1_error)
10938
10940
  }
10939
10941
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10940
10942
  for (;;) {
10941
- if (likely(!__pyx_t_9)) {
10943
+ if (likely(!__pyx_t_10)) {
10942
10944
  if (likely(PyList_CheckExact(__pyx_t_1))) {
10943
10945
  {
10944
10946
  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
10945
10947
  #if !CYTHON_ASSUME_SAFE_MACROS
10946
10948
  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 482, __pyx_L1_error)
10947
10949
  #endif
10948
- if (__pyx_t_8 >= __pyx_temp) break;
10950
+ if (__pyx_t_9 >= __pyx_temp) break;
10949
10951
  }
10950
10952
  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10951
- __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 482, __pyx_L1_error)
10953
+ __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 482, __pyx_L1_error)
10952
10954
  #else
10953
- __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 482, __pyx_L1_error)
10955
+ __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 482, __pyx_L1_error)
10954
10956
  __Pyx_GOTREF(__pyx_t_2);
10955
10957
  #endif
10956
10958
  } else {
@@ -10959,17 +10961,17 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_10set_vertex_
10959
10961
  #if !CYTHON_ASSUME_SAFE_MACROS
10960
10962
  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 482, __pyx_L1_error)
10961
10963
  #endif
10962
- if (__pyx_t_8 >= __pyx_temp) break;
10964
+ if (__pyx_t_9 >= __pyx_temp) break;
10963
10965
  }
10964
10966
  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10965
- __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 482, __pyx_L1_error)
10967
+ __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 482, __pyx_L1_error)
10966
10968
  #else
10967
- __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 482, __pyx_L1_error)
10969
+ __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 482, __pyx_L1_error)
10968
10970
  __Pyx_GOTREF(__pyx_t_2);
10969
10971
  #endif
10970
10972
  }
10971
10973
  } else {
10972
- __pyx_t_2 = __pyx_t_9(__pyx_t_1);
10974
+ __pyx_t_2 = __pyx_t_10(__pyx_t_1);
10973
10975
  if (unlikely(!__pyx_t_2)) {
10974
10976
  PyObject* exc_type = PyErr_Occurred();
10975
10977
  if (exc_type) {
@@ -10998,19 +11000,19 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_10set_vertex_
10998
11000
  __Pyx_INCREF(__pyx_v_j);
10999
11001
  __Pyx_GIVEREF(__pyx_v_j);
11000
11002
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_j)) __PYX_ERR(0, 483, __pyx_L1_error);
11001
- __pyx_t_10 = __Pyx_PyObject_GetItem(__pyx_v_vertex_attributes, __pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 483, __pyx_L1_error)
11002
- __Pyx_GOTREF(__pyx_t_10);
11003
+ __pyx_t_11 = __Pyx_PyObject_GetItem(__pyx_v_vertex_attributes, __pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 483, __pyx_L1_error)
11004
+ __Pyx_GOTREF(__pyx_t_11);
11003
11005
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11004
- __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_10); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 483, __pyx_L1_error)
11005
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
11006
- __pyx_t_10 = PyNumber_Multiply(__pyx_v_i, __pyx_v_num_attr); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 483, __pyx_L1_error)
11007
- __Pyx_GOTREF(__pyx_t_10);
11008
- __pyx_t_2 = PyNumber_Add(__pyx_t_10, __pyx_v_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 483, __pyx_L1_error)
11006
+ __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_11); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 483, __pyx_L1_error)
11007
+ __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
11008
+ __pyx_t_11 = PyNumber_Multiply(__pyx_v_i, __pyx_v_num_attr); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 483, __pyx_L1_error)
11009
+ __Pyx_GOTREF(__pyx_t_11);
11010
+ __pyx_t_2 = PyNumber_Add(__pyx_t_11, __pyx_v_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 483, __pyx_L1_error)
11009
11011
  __Pyx_GOTREF(__pyx_t_2);
11010
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
11011
- __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 483, __pyx_L1_error)
11012
+ __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
11013
+ __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 483, __pyx_L1_error)
11012
11014
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11013
- (__pyx_v_self->_io->pointattributelist[__pyx_t_12]) = __pyx_t_11;
11015
+ (__pyx_v_self->_io->pointattributelist[__pyx_t_13]) = __pyx_t_12;
11014
11016
 
11015
11017
  /* "cytriangle/cytriangleio.pyx":482
11016
11018
  * self._io.numberofpointattributes = num_attr
@@ -11047,7 +11049,7 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_10set_vertex_
11047
11049
  __Pyx_XDECREF(__pyx_t_1);
11048
11050
  __Pyx_XDECREF(__pyx_t_2);
11049
11051
  __Pyx_XDECREF(__pyx_t_3);
11050
- __Pyx_XDECREF(__pyx_t_10);
11052
+ __Pyx_XDECREF(__pyx_t_11);
11051
11053
  __Pyx_AddTraceback("cytriangle.cytriangleio.TriangleIO.set_vertex_attributes", __pyx_clineno, __pyx_lineno, __pyx_filename);
11052
11054
  __pyx_r = NULL;
11053
11055
  __pyx_L0:;
@@ -11804,15 +11806,16 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_16set_triangl
11804
11806
  PyObject *__pyx_t_1 = NULL;
11805
11807
  PyObject *__pyx_t_2 = NULL;
11806
11808
  PyObject *__pyx_t_3 = NULL;
11807
- int __pyx_t_4;
11809
+ unsigned int __pyx_t_4;
11808
11810
  size_t __pyx_t_5;
11809
- Py_ssize_t __pyx_t_6;
11810
- PyObject *(*__pyx_t_7)(PyObject *);
11811
- Py_ssize_t __pyx_t_8;
11812
- PyObject *(*__pyx_t_9)(PyObject *);
11813
- PyObject *__pyx_t_10 = NULL;
11814
- double __pyx_t_11;
11815
- Py_ssize_t __pyx_t_12;
11811
+ int __pyx_t_6;
11812
+ Py_ssize_t __pyx_t_7;
11813
+ PyObject *(*__pyx_t_8)(PyObject *);
11814
+ Py_ssize_t __pyx_t_9;
11815
+ PyObject *(*__pyx_t_10)(PyObject *);
11816
+ PyObject *__pyx_t_11 = NULL;
11817
+ double __pyx_t_12;
11818
+ Py_ssize_t __pyx_t_13;
11816
11819
  int __pyx_lineno = 0;
11817
11820
  const char *__pyx_filename = NULL;
11818
11821
  int __pyx_clineno = 0;
@@ -11969,8 +11972,8 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_16set_triangl
11969
11972
  * for i in range(num_triangles):
11970
11973
  * for j in range(num_attr):
11971
11974
  */
11972
- __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_num_attr); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 508, __pyx_L1_error)
11973
- __pyx_v_self->_io->numberoftriangleattributes = __pyx_t_4;
11975
+ __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_num_attr); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 508, __pyx_L1_error)
11976
+ __pyx_v_self->_io->numberoftriangleattributes = __pyx_t_6;
11974
11977
 
11975
11978
  /* "cytriangle/cytriangleio.pyx":509
11976
11979
  * num_attr * num_triangles * sizeof(double))
@@ -11983,28 +11986,28 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_16set_triangl
11983
11986
  __Pyx_GOTREF(__pyx_t_2);
11984
11987
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
11985
11988
  __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3);
11986
- __pyx_t_6 = 0;
11987
- __pyx_t_7 = NULL;
11989
+ __pyx_t_7 = 0;
11990
+ __pyx_t_8 = NULL;
11988
11991
  } else {
11989
- __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 509, __pyx_L1_error)
11992
+ __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 509, __pyx_L1_error)
11990
11993
  __Pyx_GOTREF(__pyx_t_3);
11991
- __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 509, __pyx_L1_error)
11994
+ __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 509, __pyx_L1_error)
11992
11995
  }
11993
11996
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11994
11997
  for (;;) {
11995
- if (likely(!__pyx_t_7)) {
11998
+ if (likely(!__pyx_t_8)) {
11996
11999
  if (likely(PyList_CheckExact(__pyx_t_3))) {
11997
12000
  {
11998
12001
  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3);
11999
12002
  #if !CYTHON_ASSUME_SAFE_MACROS
12000
12003
  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 509, __pyx_L1_error)
12001
12004
  #endif
12002
- if (__pyx_t_6 >= __pyx_temp) break;
12005
+ if (__pyx_t_7 >= __pyx_temp) break;
12003
12006
  }
12004
12007
  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12005
- __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 509, __pyx_L1_error)
12008
+ __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 509, __pyx_L1_error)
12006
12009
  #else
12007
- __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 509, __pyx_L1_error)
12010
+ __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 509, __pyx_L1_error)
12008
12011
  __Pyx_GOTREF(__pyx_t_2);
12009
12012
  #endif
12010
12013
  } else {
@@ -12013,17 +12016,17 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_16set_triangl
12013
12016
  #if !CYTHON_ASSUME_SAFE_MACROS
12014
12017
  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 509, __pyx_L1_error)
12015
12018
  #endif
12016
- if (__pyx_t_6 >= __pyx_temp) break;
12019
+ if (__pyx_t_7 >= __pyx_temp) break;
12017
12020
  }
12018
12021
  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12019
- __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 509, __pyx_L1_error)
12022
+ __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 509, __pyx_L1_error)
12020
12023
  #else
12021
- __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 509, __pyx_L1_error)
12024
+ __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 509, __pyx_L1_error)
12022
12025
  __Pyx_GOTREF(__pyx_t_2);
12023
12026
  #endif
12024
12027
  }
12025
12028
  } else {
12026
- __pyx_t_2 = __pyx_t_7(__pyx_t_3);
12029
+ __pyx_t_2 = __pyx_t_8(__pyx_t_3);
12027
12030
  if (unlikely(!__pyx_t_2)) {
12028
12031
  PyObject* exc_type = PyErr_Occurred();
12029
12032
  if (exc_type) {
@@ -12048,28 +12051,28 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_16set_triangl
12048
12051
  __Pyx_GOTREF(__pyx_t_2);
12049
12052
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
12050
12053
  __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1);
12051
- __pyx_t_8 = 0;
12052
- __pyx_t_9 = NULL;
12054
+ __pyx_t_9 = 0;
12055
+ __pyx_t_10 = NULL;
12053
12056
  } else {
12054
- __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 510, __pyx_L1_error)
12057
+ __pyx_t_9 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 510, __pyx_L1_error)
12055
12058
  __Pyx_GOTREF(__pyx_t_1);
12056
- __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 510, __pyx_L1_error)
12059
+ __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 510, __pyx_L1_error)
12057
12060
  }
12058
12061
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12059
12062
  for (;;) {
12060
- if (likely(!__pyx_t_9)) {
12063
+ if (likely(!__pyx_t_10)) {
12061
12064
  if (likely(PyList_CheckExact(__pyx_t_1))) {
12062
12065
  {
12063
12066
  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
12064
12067
  #if !CYTHON_ASSUME_SAFE_MACROS
12065
12068
  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 510, __pyx_L1_error)
12066
12069
  #endif
12067
- if (__pyx_t_8 >= __pyx_temp) break;
12070
+ if (__pyx_t_9 >= __pyx_temp) break;
12068
12071
  }
12069
12072
  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12070
- __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 510, __pyx_L1_error)
12073
+ __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 510, __pyx_L1_error)
12071
12074
  #else
12072
- __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 510, __pyx_L1_error)
12075
+ __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 510, __pyx_L1_error)
12073
12076
  __Pyx_GOTREF(__pyx_t_2);
12074
12077
  #endif
12075
12078
  } else {
@@ -12078,17 +12081,17 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_16set_triangl
12078
12081
  #if !CYTHON_ASSUME_SAFE_MACROS
12079
12082
  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 510, __pyx_L1_error)
12080
12083
  #endif
12081
- if (__pyx_t_8 >= __pyx_temp) break;
12084
+ if (__pyx_t_9 >= __pyx_temp) break;
12082
12085
  }
12083
12086
  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12084
- __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 510, __pyx_L1_error)
12087
+ __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 510, __pyx_L1_error)
12085
12088
  #else
12086
- __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 510, __pyx_L1_error)
12089
+ __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 510, __pyx_L1_error)
12087
12090
  __Pyx_GOTREF(__pyx_t_2);
12088
12091
  #endif
12089
12092
  }
12090
12093
  } else {
12091
- __pyx_t_2 = __pyx_t_9(__pyx_t_1);
12094
+ __pyx_t_2 = __pyx_t_10(__pyx_t_1);
12092
12095
  if (unlikely(!__pyx_t_2)) {
12093
12096
  PyObject* exc_type = PyErr_Occurred();
12094
12097
  if (exc_type) {
@@ -12117,11 +12120,11 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_16set_triangl
12117
12120
  __Pyx_INCREF(__pyx_v_j);
12118
12121
  __Pyx_GIVEREF(__pyx_v_j);
12119
12122
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_j)) __PYX_ERR(0, 512, __pyx_L1_error);
12120
- __pyx_t_10 = __Pyx_PyObject_GetItem(__pyx_v_triangle_attributes, __pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 512, __pyx_L1_error)
12121
- __Pyx_GOTREF(__pyx_t_10);
12123
+ __pyx_t_11 = __Pyx_PyObject_GetItem(__pyx_v_triangle_attributes, __pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 512, __pyx_L1_error)
12124
+ __Pyx_GOTREF(__pyx_t_11);
12122
12125
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12123
- __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_10); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 512, __pyx_L1_error)
12124
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
12126
+ __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_11); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 512, __pyx_L1_error)
12127
+ __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
12125
12128
 
12126
12129
  /* "cytriangle/cytriangleio.pyx":511
12127
12130
  * for i in range(num_triangles):
@@ -12130,8 +12133,8 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_16set_triangl
12130
12133
  * i * num_attr + j] = triangle_attributes[i, j]
12131
12134
  *
12132
12135
  */
12133
- __pyx_t_10 = PyNumber_Multiply(__pyx_v_i, __pyx_v_num_attr); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 512, __pyx_L1_error)
12134
- __Pyx_GOTREF(__pyx_t_10);
12136
+ __pyx_t_11 = PyNumber_Multiply(__pyx_v_i, __pyx_v_num_attr); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 512, __pyx_L1_error)
12137
+ __Pyx_GOTREF(__pyx_t_11);
12135
12138
 
12136
12139
  /* "cytriangle/cytriangleio.pyx":512
12137
12140
  * for j in range(num_attr):
@@ -12140,12 +12143,12 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_16set_triangl
12140
12143
  *
12141
12144
  * def set_triangle_areas(self, triangle_areas):
12142
12145
  */
12143
- __pyx_t_2 = PyNumber_Add(__pyx_t_10, __pyx_v_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 512, __pyx_L1_error)
12146
+ __pyx_t_2 = PyNumber_Add(__pyx_t_11, __pyx_v_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 512, __pyx_L1_error)
12144
12147
  __Pyx_GOTREF(__pyx_t_2);
12145
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
12146
- __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 512, __pyx_L1_error)
12148
+ __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
12149
+ __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 512, __pyx_L1_error)
12147
12150
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12148
- (__pyx_v_self->_io->triangleattributelist[__pyx_t_12]) = __pyx_t_11;
12151
+ (__pyx_v_self->_io->triangleattributelist[__pyx_t_13]) = __pyx_t_12;
12149
12152
 
12150
12153
  /* "cytriangle/cytriangleio.pyx":510
12151
12154
  * self._io.numberoftriangleattributes = num_attr
@@ -12182,7 +12185,7 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_16set_triangl
12182
12185
  __Pyx_XDECREF(__pyx_t_1);
12183
12186
  __Pyx_XDECREF(__pyx_t_2);
12184
12187
  __Pyx_XDECREF(__pyx_t_3);
12185
- __Pyx_XDECREF(__pyx_t_10);
12188
+ __Pyx_XDECREF(__pyx_t_11);
12186
12189
  __Pyx_AddTraceback("cytriangle.cytriangleio.TriangleIO.set_triangle_attributes", __pyx_clineno, __pyx_lineno, __pyx_filename);
12187
12190
  __pyx_r = NULL;
12188
12191
  __pyx_L0:;
@@ -12309,7 +12312,7 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_18set_triangl
12309
12312
  PyObject *__pyx_t_1 = NULL;
12310
12313
  PyObject *__pyx_t_2 = NULL;
12311
12314
  PyObject *__pyx_t_3 = NULL;
12312
- int __pyx_t_4;
12315
+ unsigned int __pyx_t_4;
12313
12316
  size_t __pyx_t_5;
12314
12317
  Py_ssize_t __pyx_t_6;
12315
12318
  PyObject *(*__pyx_t_7)(PyObject *);
@@ -12996,10 +12999,11 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_22set_segment
12996
12999
  PyObject *__pyx_t_2 = NULL;
12997
13000
  PyObject *__pyx_t_3 = NULL;
12998
13001
  PyObject *__pyx_t_4 = NULL;
12999
- int __pyx_t_5;
13002
+ unsigned int __pyx_t_5;
13000
13003
  int __pyx_t_6;
13001
13004
  int __pyx_t_7;
13002
13005
  int __pyx_t_8;
13006
+ int __pyx_t_9;
13003
13007
  int __pyx_lineno = 0;
13004
13008
  const char *__pyx_filename = NULL;
13005
13009
  int __pyx_clineno = 0;
@@ -13086,10 +13090,10 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_22set_segment
13086
13090
  * self._io.segmentmarkerlist[i] = segment_markers[i]
13087
13091
  *
13088
13092
  */
13089
- __pyx_t_5 = __pyx_v_self->_io->numberofsegments;
13090
- __pyx_t_6 = __pyx_t_5;
13091
- for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
13092
- __pyx_v_i = __pyx_t_7;
13093
+ __pyx_t_6 = __pyx_v_self->_io->numberofsegments;
13094
+ __pyx_t_7 = __pyx_t_6;
13095
+ for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
13096
+ __pyx_v_i = __pyx_t_8;
13093
13097
 
13094
13098
  /* "cytriangle/cytriangleio.pyx":537
13095
13099
  * self._io.numberofsegments * sizeof(int))
@@ -13100,9 +13104,9 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_22set_segment
13100
13104
  */
13101
13105
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_segment_markers, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 537, __pyx_L1_error)
13102
13106
  __Pyx_GOTREF(__pyx_t_4);
13103
- __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 537, __pyx_L1_error)
13107
+ __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 537, __pyx_L1_error)
13104
13108
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13105
- (__pyx_v_self->_io->segmentmarkerlist[__pyx_v_i]) = __pyx_t_8;
13109
+ (__pyx_v_self->_io->segmentmarkerlist[__pyx_v_i]) = __pyx_t_9;
13106
13110
  }
13107
13111
 
13108
13112
  /* "cytriangle/cytriangleio.pyx":531
@@ -13244,10 +13248,11 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_24set_holes(s
13244
13248
  int __pyx_t_3;
13245
13249
  PyObject *__pyx_t_4 = NULL;
13246
13250
  PyObject *__pyx_t_5 = NULL;
13247
- size_t __pyx_t_6;
13248
- PyObject *(*__pyx_t_7)(PyObject *);
13249
- double __pyx_t_8;
13250
- Py_ssize_t __pyx_t_9;
13251
+ unsigned int __pyx_t_6;
13252
+ size_t __pyx_t_7;
13253
+ PyObject *(*__pyx_t_8)(PyObject *);
13254
+ double __pyx_t_9;
13255
+ Py_ssize_t __pyx_t_10;
13251
13256
  int __pyx_lineno = 0;
13252
13257
  const char *__pyx_filename = NULL;
13253
13258
  int __pyx_clineno = 0;
@@ -13290,7 +13295,7 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_24set_holes(s
13290
13295
  __Pyx_GOTREF(__pyx_t_5);
13291
13296
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13292
13297
  __pyx_t_4 = NULL;
13293
- __pyx_t_3 = 0;
13298
+ __pyx_t_6 = 0;
13294
13299
  #if CYTHON_UNPACK_METHODS
13295
13300
  if (unlikely(PyMethod_Check(__pyx_t_5))) {
13296
13301
  __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
@@ -13299,13 +13304,13 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_24set_holes(s
13299
13304
  __Pyx_INCREF(__pyx_t_4);
13300
13305
  __Pyx_INCREF(function);
13301
13306
  __Pyx_DECREF_SET(__pyx_t_5, function);
13302
- __pyx_t_3 = 1;
13307
+ __pyx_t_6 = 1;
13303
13308
  }
13304
13309
  }
13305
13310
  #endif
13306
13311
  {
13307
13312
  PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_holes};
13308
- __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_3, 1+__pyx_t_3);
13313
+ __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6);
13309
13314
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
13310
13315
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 542, __pyx_L1_error)
13311
13316
  __Pyx_GOTREF(__pyx_t_2);
@@ -13329,9 +13334,9 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_24set_holes(s
13329
13334
  __Pyx_GOTREF(__pyx_t_4);
13330
13335
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13331
13336
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
13332
- __pyx_t_6 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_6 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 543, __pyx_L1_error)
13337
+ __pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 543, __pyx_L1_error)
13333
13338
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13334
- __pyx_v_self->_io->holelist = ((double *)malloc(__pyx_t_6));
13339
+ __pyx_v_self->_io->holelist = ((double *)malloc(__pyx_t_7));
13335
13340
 
13336
13341
  /* "cytriangle/cytriangleio.pyx":544
13337
13342
  * holes = np.ascontiguousarray(holes)
@@ -13345,15 +13350,15 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_24set_holes(s
13345
13350
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
13346
13351
  __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5);
13347
13352
  __pyx_t_1 = 0;
13348
- __pyx_t_7 = NULL;
13353
+ __pyx_t_8 = NULL;
13349
13354
  } else {
13350
13355
  __pyx_t_1 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 544, __pyx_L1_error)
13351
13356
  __Pyx_GOTREF(__pyx_t_5);
13352
- __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 544, __pyx_L1_error)
13357
+ __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 544, __pyx_L1_error)
13353
13358
  }
13354
13359
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13355
13360
  for (;;) {
13356
- if (likely(!__pyx_t_7)) {
13361
+ if (likely(!__pyx_t_8)) {
13357
13362
  if (likely(PyList_CheckExact(__pyx_t_5))) {
13358
13363
  {
13359
13364
  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
@@ -13384,7 +13389,7 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_24set_holes(s
13384
13389
  #endif
13385
13390
  }
13386
13391
  } else {
13387
- __pyx_t_4 = __pyx_t_7(__pyx_t_5);
13392
+ __pyx_t_4 = __pyx_t_8(__pyx_t_5);
13388
13393
  if (unlikely(!__pyx_t_4)) {
13389
13394
  PyObject* exc_type = PyErr_Occurred();
13390
13395
  if (exc_type) {
@@ -13416,13 +13421,13 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_24set_holes(s
13416
13421
  __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_holes, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 545, __pyx_L1_error)
13417
13422
  __Pyx_GOTREF(__pyx_t_2);
13418
13423
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13419
- __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 545, __pyx_L1_error)
13424
+ __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 545, __pyx_L1_error)
13420
13425
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13421
13426
  __pyx_t_2 = __Pyx_PyInt_MultiplyCObj(__pyx_int_2, __pyx_v_i, 2, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 545, __pyx_L1_error)
13422
13427
  __Pyx_GOTREF(__pyx_t_2);
13423
- __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 545, __pyx_L1_error)
13428
+ __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 545, __pyx_L1_error)
13424
13429
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13425
- (__pyx_v_self->_io->holelist[__pyx_t_9]) = __pyx_t_8;
13430
+ (__pyx_v_self->_io->holelist[__pyx_t_10]) = __pyx_t_9;
13426
13431
 
13427
13432
  /* "cytriangle/cytriangleio.pyx":546
13428
13433
  * for i in range(num_holes):
@@ -13442,16 +13447,16 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_24set_holes(s
13442
13447
  __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_holes, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 546, __pyx_L1_error)
13443
13448
  __Pyx_GOTREF(__pyx_t_4);
13444
13449
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13445
- __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 546, __pyx_L1_error)
13450
+ __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 546, __pyx_L1_error)
13446
13451
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13447
13452
  __pyx_t_4 = __Pyx_PyInt_MultiplyCObj(__pyx_int_2, __pyx_v_i, 2, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 546, __pyx_L1_error)
13448
13453
  __Pyx_GOTREF(__pyx_t_4);
13449
13454
  __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 546, __pyx_L1_error)
13450
13455
  __Pyx_GOTREF(__pyx_t_2);
13451
13456
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13452
- __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 546, __pyx_L1_error)
13457
+ __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 546, __pyx_L1_error)
13453
13458
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13454
- (__pyx_v_self->_io->holelist[__pyx_t_9]) = __pyx_t_8;
13459
+ (__pyx_v_self->_io->holelist[__pyx_t_10]) = __pyx_t_9;
13455
13460
 
13456
13461
  /* "cytriangle/cytriangleio.pyx":544
13457
13462
  * holes = np.ascontiguousarray(holes)
@@ -13611,10 +13616,11 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_26set_regions
13611
13616
  PyObject *__pyx_t_8 = NULL;
13612
13617
  PyObject *__pyx_t_9 = NULL;
13613
13618
  PyObject *__pyx_t_10 = NULL;
13614
- size_t __pyx_t_11;
13615
- long __pyx_t_12;
13616
- double __pyx_t_13;
13617
- Py_ssize_t __pyx_t_14;
13619
+ unsigned int __pyx_t_11;
13620
+ size_t __pyx_t_12;
13621
+ long __pyx_t_13;
13622
+ double __pyx_t_14;
13623
+ Py_ssize_t __pyx_t_15;
13618
13624
  int __pyx_lineno = 0;
13619
13625
  const char *__pyx_filename = NULL;
13620
13626
  int __pyx_clineno = 0;
@@ -13819,7 +13825,7 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_26set_regions
13819
13825
  __Pyx_GOTREF(__pyx_t_10);
13820
13826
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13821
13827
  __pyx_t_4 = NULL;
13822
- __pyx_t_3 = 0;
13828
+ __pyx_t_11 = 0;
13823
13829
  #if CYTHON_UNPACK_METHODS
13824
13830
  if (unlikely(PyMethod_Check(__pyx_t_10))) {
13825
13831
  __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
@@ -13828,13 +13834,13 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_26set_regions
13828
13834
  __Pyx_INCREF(__pyx_t_4);
13829
13835
  __Pyx_INCREF(function);
13830
13836
  __Pyx_DECREF_SET(__pyx_t_10, function);
13831
- __pyx_t_3 = 1;
13837
+ __pyx_t_11 = 1;
13832
13838
  }
13833
13839
  }
13834
13840
  #endif
13835
13841
  {
13836
13842
  PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_region_array};
13837
- __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_3, 1+__pyx_t_3);
13843
+ __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11);
13838
13844
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
13839
13845
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 557, __pyx_L1_error)
13840
13846
  __Pyx_GOTREF(__pyx_t_2);
@@ -13858,9 +13864,9 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_26set_regions
13858
13864
  __Pyx_GOTREF(__pyx_t_4);
13859
13865
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13860
13866
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
13861
- __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 558, __pyx_L1_error)
13867
+ __pyx_t_12 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_12 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 558, __pyx_L1_error)
13862
13868
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13863
- __pyx_v_self->_io->regionlist = ((double *)malloc(__pyx_t_11));
13869
+ __pyx_v_self->_io->regionlist = ((double *)malloc(__pyx_t_12));
13864
13870
 
13865
13871
  /* "cytriangle/cytriangleio.pyx":559
13866
13872
  * regions = np.ascontiguousarray(region_array)
@@ -13933,8 +13939,8 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_26set_regions
13933
13939
  * for j in range(4): # <<<<<<<<<<<<<<
13934
13940
  * self._io.regionlist[i * 4 + j] = regions[i, j]
13935
13941
  */
13936
- for (__pyx_t_12 = 0; __pyx_t_12 < 4; __pyx_t_12+=1) {
13937
- __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 560, __pyx_L1_error)
13942
+ for (__pyx_t_13 = 0; __pyx_t_13 < 4; __pyx_t_13+=1) {
13943
+ __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 560, __pyx_L1_error)
13938
13944
  __Pyx_GOTREF(__pyx_t_4);
13939
13945
  __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_4);
13940
13946
  __pyx_t_4 = 0;
@@ -13955,16 +13961,16 @@ static PyObject *__pyx_pf_10cytriangle_12cytriangleio_10TriangleIO_26set_regions
13955
13961
  __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_regions, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 561, __pyx_L1_error)
13956
13962
  __Pyx_GOTREF(__pyx_t_2);
13957
13963
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13958
- __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 561, __pyx_L1_error)
13964
+ __pyx_t_14 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_14 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 561, __pyx_L1_error)
13959
13965
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13960
13966
  __pyx_t_2 = __Pyx_PyInt_MultiplyObjC(__pyx_v_i, __pyx_int_4, 4, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 561, __pyx_L1_error)
13961
13967
  __Pyx_GOTREF(__pyx_t_2);
13962
13968
  __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_v_j); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 561, __pyx_L1_error)
13963
13969
  __Pyx_GOTREF(__pyx_t_4);
13964
13970
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13965
- __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 561, __pyx_L1_error)
13971
+ __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 561, __pyx_L1_error)
13966
13972
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13967
- (__pyx_v_self->_io->regionlist[__pyx_t_14]) = __pyx_t_13;
13973
+ (__pyx_v_self->_io->regionlist[__pyx_t_15]) = __pyx_t_14;
13968
13974
  }
13969
13975
 
13970
13976
  /* "cytriangle/cytriangleio.pyx":559
@@ -14554,6 +14560,9 @@ static PyTypeObject __pyx_type_10cytriangle_12cytriangleio_TriangleIO = {
14554
14560
  #if PY_VERSION_HEX >= 0x030C0000
14555
14561
  0, /*tp_watched*/
14556
14562
  #endif
14563
+ #if PY_VERSION_HEX >= 0x030d00A4
14564
+ 0, /*tp_versions_used*/
14565
+ #endif
14557
14566
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
14558
14567
  0, /*tp_pypy_flags*/
14559
14568
  #endif
@@ -19254,6 +19263,9 @@ static PyTypeObject __pyx_CyFunctionType_type = {
19254
19263
  #if PY_VERSION_HEX >= 0x030C0000
19255
19264
  0,
19256
19265
  #endif
19266
+ #if PY_VERSION_HEX >= 0x030d00A4
19267
+ 0,
19268
+ #endif
19257
19269
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
19258
19270
  0,
19259
19271
  #endif
@@ -19680,12 +19692,19 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
19680
19692
  }
19681
19693
  }
19682
19694
  {
19683
- int one = 1; int little = (int)*(unsigned char *)&one;
19684
19695
  unsigned char *bytes = (unsigned char *)&value;
19685
- #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
19696
+ #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
19697
+ if (is_unsigned) {
19698
+ return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
19699
+ } else {
19700
+ return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
19701
+ }
19702
+ #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
19703
+ int one = 1; int little = (int)*(unsigned char *)&one;
19686
19704
  return _PyLong_FromByteArray(bytes, sizeof(long),
19687
19705
  little, !is_unsigned);
19688
19706
  #else
19707
+ int one = 1; int little = (int)*(unsigned char *)&one;
19689
19708
  PyObject *from_bytes, *result = NULL;
19690
19709
  PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL;
19691
19710
  from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
@@ -19744,12 +19763,19 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
19744
19763
  }
19745
19764
  }
19746
19765
  {
19747
- int one = 1; int little = (int)*(unsigned char *)&one;
19748
19766
  unsigned char *bytes = (unsigned char *)&value;
19749
- #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
19767
+ #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
19768
+ if (is_unsigned) {
19769
+ return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
19770
+ } else {
19771
+ return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
19772
+ }
19773
+ #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
19774
+ int one = 1; int little = (int)*(unsigned char *)&one;
19750
19775
  return _PyLong_FromByteArray(bytes, sizeof(int),
19751
19776
  little, !is_unsigned);
19752
19777
  #else
19778
+ int one = 1; int little = (int)*(unsigned char *)&one;
19753
19779
  PyObject *from_bytes, *result = NULL;
19754
19780
  PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL;
19755
19781
  from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
@@ -19799,245 +19825,239 @@ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
19799
19825
  }
19800
19826
  return (int) val;
19801
19827
  }
19802
- } else
19828
+ }
19803
19829
  #endif
19804
- if (likely(PyLong_Check(x))) {
19805
- if (is_unsigned) {
19830
+ if (unlikely(!PyLong_Check(x))) {
19831
+ int val;
19832
+ PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
19833
+ if (!tmp) return (int) -1;
19834
+ val = __Pyx_PyInt_As_int(tmp);
19835
+ Py_DECREF(tmp);
19836
+ return val;
19837
+ }
19838
+ if (is_unsigned) {
19806
19839
  #if CYTHON_USE_PYLONG_INTERNALS
19807
- if (unlikely(__Pyx_PyLong_IsNeg(x))) {
19808
- goto raise_neg_overflow;
19809
- } else if (__Pyx_PyLong_IsCompact(x)) {
19810
- __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
19811
- } else {
19812
- const digit* digits = __Pyx_PyLong_Digits(x);
19813
- assert(__Pyx_PyLong_DigitCount(x) > 1);
19814
- switch (__Pyx_PyLong_DigitCount(x)) {
19815
- case 2:
19816
- if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
19817
- if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
19818
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19819
- } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) {
19820
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
19821
- }
19840
+ if (unlikely(__Pyx_PyLong_IsNeg(x))) {
19841
+ goto raise_neg_overflow;
19842
+ } else if (__Pyx_PyLong_IsCompact(x)) {
19843
+ __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
19844
+ } else {
19845
+ const digit* digits = __Pyx_PyLong_Digits(x);
19846
+ assert(__Pyx_PyLong_DigitCount(x) > 1);
19847
+ switch (__Pyx_PyLong_DigitCount(x)) {
19848
+ case 2:
19849
+ if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
19850
+ if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
19851
+ __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19852
+ } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) {
19853
+ return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
19822
19854
  }
19823
- break;
19824
- case 3:
19825
- if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
19826
- if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
19827
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19828
- } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) {
19829
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
19830
- }
19855
+ }
19856
+ break;
19857
+ case 3:
19858
+ if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
19859
+ if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
19860
+ __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19861
+ } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) {
19862
+ return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
19831
19863
  }
19832
- break;
19833
- case 4:
19834
- if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
19835
- if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
19836
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19837
- } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) {
19838
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
19839
- }
19864
+ }
19865
+ break;
19866
+ case 4:
19867
+ if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
19868
+ if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
19869
+ __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19870
+ } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) {
19871
+ return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
19840
19872
  }
19841
- break;
19842
- }
19873
+ }
19874
+ break;
19843
19875
  }
19876
+ }
19844
19877
  #endif
19845
19878
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
19846
- if (unlikely(Py_SIZE(x) < 0)) {
19847
- goto raise_neg_overflow;
19848
- }
19879
+ if (unlikely(Py_SIZE(x) < 0)) {
19880
+ goto raise_neg_overflow;
19881
+ }
19849
19882
  #else
19850
- {
19851
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
19852
- if (unlikely(result < 0))
19853
- return (int) -1;
19854
- if (unlikely(result == 1))
19855
- goto raise_neg_overflow;
19856
- }
19883
+ {
19884
+ int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
19885
+ if (unlikely(result < 0))
19886
+ return (int) -1;
19887
+ if (unlikely(result == 1))
19888
+ goto raise_neg_overflow;
19889
+ }
19857
19890
  #endif
19858
- if ((sizeof(int) <= sizeof(unsigned long))) {
19859
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
19891
+ if ((sizeof(int) <= sizeof(unsigned long))) {
19892
+ __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
19860
19893
  #ifdef HAVE_LONG_LONG
19861
- } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) {
19862
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
19894
+ } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) {
19895
+ __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
19863
19896
  #endif
19864
- }
19865
- } else {
19897
+ }
19898
+ } else {
19866
19899
  #if CYTHON_USE_PYLONG_INTERNALS
19867
- if (__Pyx_PyLong_IsCompact(x)) {
19868
- __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
19869
- } else {
19870
- const digit* digits = __Pyx_PyLong_Digits(x);
19871
- assert(__Pyx_PyLong_DigitCount(x) > 1);
19872
- switch (__Pyx_PyLong_SignedDigitCount(x)) {
19873
- case -2:
19874
- if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) {
19875
- if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
19876
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19877
- } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
19878
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
19879
- }
19900
+ if (__Pyx_PyLong_IsCompact(x)) {
19901
+ __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
19902
+ } else {
19903
+ const digit* digits = __Pyx_PyLong_Digits(x);
19904
+ assert(__Pyx_PyLong_DigitCount(x) > 1);
19905
+ switch (__Pyx_PyLong_SignedDigitCount(x)) {
19906
+ case -2:
19907
+ if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) {
19908
+ if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
19909
+ __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19910
+ } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
19911
+ return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
19880
19912
  }
19881
- break;
19882
- case 2:
19883
- if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
19884
- if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
19885
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19886
- } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
19887
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
19888
- }
19913
+ }
19914
+ break;
19915
+ case 2:
19916
+ if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
19917
+ if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
19918
+ __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19919
+ } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
19920
+ return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
19889
19921
  }
19890
- break;
19891
- case -3:
19892
- if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
19893
- if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
19894
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19895
- } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
19896
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
19897
- }
19922
+ }
19923
+ break;
19924
+ case -3:
19925
+ if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
19926
+ if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
19927
+ __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19928
+ } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
19929
+ return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
19898
19930
  }
19899
- break;
19900
- case 3:
19901
- if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
19902
- if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
19903
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19904
- } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
19905
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
19906
- }
19931
+ }
19932
+ break;
19933
+ case 3:
19934
+ if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
19935
+ if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
19936
+ __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19937
+ } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
19938
+ return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
19907
19939
  }
19908
- break;
19909
- case -4:
19910
- if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
19911
- if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
19912
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19913
- } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
19914
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
19915
- }
19940
+ }
19941
+ break;
19942
+ case -4:
19943
+ if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
19944
+ if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
19945
+ __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19946
+ } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
19947
+ return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
19916
19948
  }
19917
- break;
19918
- case 4:
19919
- if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
19920
- if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
19921
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19922
- } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
19923
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
19924
- }
19949
+ }
19950
+ break;
19951
+ case 4:
19952
+ if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
19953
+ if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
19954
+ __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
19955
+ } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
19956
+ return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
19925
19957
  }
19926
- break;
19927
- }
19958
+ }
19959
+ break;
19928
19960
  }
19961
+ }
19929
19962
  #endif
19930
- if ((sizeof(int) <= sizeof(long))) {
19931
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
19963
+ if ((sizeof(int) <= sizeof(long))) {
19964
+ __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
19932
19965
  #ifdef HAVE_LONG_LONG
19933
- } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) {
19934
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
19966
+ } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) {
19967
+ __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
19935
19968
  #endif
19936
- }
19937
19969
  }
19938
- {
19939
- int val;
19940
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
19941
- #if PY_MAJOR_VERSION < 3
19942
- if (likely(v) && !PyLong_Check(v)) {
19943
- PyObject *tmp = v;
19944
- v = PyNumber_Long(tmp);
19945
- Py_DECREF(tmp);
19946
- }
19947
- #endif
19948
- if (likely(v)) {
19949
- int ret = -1;
19950
- #if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
19951
- int one = 1; int is_little = (int)*(unsigned char *)&one;
19952
- unsigned char *bytes = (unsigned char *)&val;
19953
- ret = _PyLong_AsByteArray((PyLongObject *)v,
19954
- bytes, sizeof(val),
19955
- is_little, !is_unsigned);
19956
- #else
19957
- PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
19958
- int bits, remaining_bits, is_negative = 0;
19959
- long idigit;
19960
- int chunk_size = (sizeof(long) < 8) ? 30 : 62;
19961
- if (unlikely(!PyLong_CheckExact(v))) {
19962
- PyObject *tmp = v;
19963
- v = PyNumber_Long(v);
19964
- assert(PyLong_CheckExact(v));
19965
- Py_DECREF(tmp);
19966
- if (unlikely(!v)) return (int) -1;
19967
- }
19968
- #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
19969
- if (Py_SIZE(x) == 0)
19970
- return (int) 0;
19971
- is_negative = Py_SIZE(x) < 0;
19970
+ }
19971
+ {
19972
+ int val;
19973
+ int ret = -1;
19974
+ #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
19975
+ Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
19976
+ x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
19977
+ if (unlikely(bytes_copied == -1)) {
19978
+ } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
19979
+ goto raise_overflow;
19980
+ } else {
19981
+ ret = 0;
19982
+ }
19983
+ #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
19984
+ int one = 1; int is_little = (int)*(unsigned char *)&one;
19985
+ unsigned char *bytes = (unsigned char *)&val;
19986
+ ret = _PyLong_AsByteArray((PyLongObject *)x,
19987
+ bytes, sizeof(val),
19988
+ is_little, !is_unsigned);
19972
19989
  #else
19973
- {
19974
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
19975
- if (unlikely(result < 0))
19976
- return (int) -1;
19977
- is_negative = result == 1;
19978
- }
19979
- #endif
19980
- if (is_unsigned && unlikely(is_negative)) {
19981
- goto raise_neg_overflow;
19982
- } else if (is_negative) {
19983
- stepval = PyNumber_Invert(v);
19984
- if (unlikely(!stepval))
19985
- return (int) -1;
19986
- } else {
19987
- stepval = __Pyx_NewRef(v);
19988
- }
19989
- val = (int) 0;
19990
- mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
19991
- shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
19992
- for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
19993
- PyObject *tmp, *digit;
19994
- digit = PyNumber_And(stepval, mask);
19995
- if (unlikely(!digit)) goto done;
19996
- idigit = PyLong_AsLong(digit);
19997
- Py_DECREF(digit);
19998
- if (unlikely(idigit < 0)) goto done;
19999
- tmp = PyNumber_Rshift(stepval, shift);
20000
- if (unlikely(!tmp)) goto done;
20001
- Py_DECREF(stepval); stepval = tmp;
20002
- val |= ((int) idigit) << bits;
20003
- #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
20004
- if (Py_SIZE(stepval) == 0)
20005
- goto unpacking_done;
20006
- #endif
20007
- }
20008
- idigit = PyLong_AsLong(stepval);
20009
- if (unlikely(idigit < 0)) goto done;
20010
- remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
20011
- if (unlikely(idigit >= (1L << remaining_bits)))
20012
- goto raise_overflow;
20013
- val |= ((int) idigit) << bits;
20014
- #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
20015
- unpacking_done:
20016
- #endif
20017
- if (!is_unsigned) {
20018
- if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
20019
- goto raise_overflow;
20020
- if (is_negative)
20021
- val = ~val;
20022
- }
20023
- ret = 0;
20024
- done:
20025
- Py_XDECREF(shift);
20026
- Py_XDECREF(mask);
20027
- Py_XDECREF(stepval);
20028
- #endif
19990
+ PyObject *v;
19991
+ PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
19992
+ int bits, remaining_bits, is_negative = 0;
19993
+ int chunk_size = (sizeof(long) < 8) ? 30 : 62;
19994
+ if (likely(PyLong_CheckExact(x))) {
19995
+ v = __Pyx_NewRef(x);
19996
+ } else {
19997
+ v = PyNumber_Long(x);
19998
+ if (unlikely(!v)) return (int) -1;
19999
+ assert(PyLong_CheckExact(v));
20000
+ }
20001
+ {
20002
+ int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
20003
+ if (unlikely(result < 0)) {
20029
20004
  Py_DECREF(v);
20030
- if (likely(!ret))
20031
- return val;
20005
+ return (int) -1;
20032
20006
  }
20033
- return (int) -1;
20007
+ is_negative = result == 1;
20034
20008
  }
20035
- } else {
20036
- int val;
20037
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
20038
- if (!tmp) return (int) -1;
20039
- val = __Pyx_PyInt_As_int(tmp);
20040
- Py_DECREF(tmp);
20009
+ if (is_unsigned && unlikely(is_negative)) {
20010
+ Py_DECREF(v);
20011
+ goto raise_neg_overflow;
20012
+ } else if (is_negative) {
20013
+ stepval = PyNumber_Invert(v);
20014
+ Py_DECREF(v);
20015
+ if (unlikely(!stepval))
20016
+ return (int) -1;
20017
+ } else {
20018
+ stepval = v;
20019
+ }
20020
+ v = NULL;
20021
+ val = (int) 0;
20022
+ mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
20023
+ shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
20024
+ for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
20025
+ PyObject *tmp, *digit;
20026
+ long idigit;
20027
+ digit = PyNumber_And(stepval, mask);
20028
+ if (unlikely(!digit)) goto done;
20029
+ idigit = PyLong_AsLong(digit);
20030
+ Py_DECREF(digit);
20031
+ if (unlikely(idigit < 0)) goto done;
20032
+ val |= ((int) idigit) << bits;
20033
+ tmp = PyNumber_Rshift(stepval, shift);
20034
+ if (unlikely(!tmp)) goto done;
20035
+ Py_DECREF(stepval); stepval = tmp;
20036
+ }
20037
+ Py_DECREF(shift); shift = NULL;
20038
+ Py_DECREF(mask); mask = NULL;
20039
+ {
20040
+ long idigit = PyLong_AsLong(stepval);
20041
+ if (unlikely(idigit < 0)) goto done;
20042
+ remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
20043
+ if (unlikely(idigit >= (1L << remaining_bits)))
20044
+ goto raise_overflow;
20045
+ val |= ((int) idigit) << bits;
20046
+ }
20047
+ if (!is_unsigned) {
20048
+ if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
20049
+ goto raise_overflow;
20050
+ if (is_negative)
20051
+ val = ~val;
20052
+ }
20053
+ ret = 0;
20054
+ done:
20055
+ Py_XDECREF(shift);
20056
+ Py_XDECREF(mask);
20057
+ Py_XDECREF(stepval);
20058
+ #endif
20059
+ if (unlikely(ret))
20060
+ return (int) -1;
20041
20061
  return val;
20042
20062
  }
20043
20063
  raise_overflow:
@@ -20072,245 +20092,239 @@ static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
20072
20092
  }
20073
20093
  return (size_t) val;
20074
20094
  }
20075
- } else
20095
+ }
20076
20096
  #endif
20077
- if (likely(PyLong_Check(x))) {
20078
- if (is_unsigned) {
20097
+ if (unlikely(!PyLong_Check(x))) {
20098
+ size_t val;
20099
+ PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
20100
+ if (!tmp) return (size_t) -1;
20101
+ val = __Pyx_PyInt_As_size_t(tmp);
20102
+ Py_DECREF(tmp);
20103
+ return val;
20104
+ }
20105
+ if (is_unsigned) {
20079
20106
  #if CYTHON_USE_PYLONG_INTERNALS
20080
- if (unlikely(__Pyx_PyLong_IsNeg(x))) {
20081
- goto raise_neg_overflow;
20082
- } else if (__Pyx_PyLong_IsCompact(x)) {
20083
- __PYX_VERIFY_RETURN_INT(size_t, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
20084
- } else {
20085
- const digit* digits = __Pyx_PyLong_Digits(x);
20086
- assert(__Pyx_PyLong_DigitCount(x) > 1);
20087
- switch (__Pyx_PyLong_DigitCount(x)) {
20088
- case 2:
20089
- if ((8 * sizeof(size_t) > 1 * PyLong_SHIFT)) {
20090
- if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
20091
- __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20092
- } else if ((8 * sizeof(size_t) >= 2 * PyLong_SHIFT)) {
20093
- return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
20094
- }
20107
+ if (unlikely(__Pyx_PyLong_IsNeg(x))) {
20108
+ goto raise_neg_overflow;
20109
+ } else if (__Pyx_PyLong_IsCompact(x)) {
20110
+ __PYX_VERIFY_RETURN_INT(size_t, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
20111
+ } else {
20112
+ const digit* digits = __Pyx_PyLong_Digits(x);
20113
+ assert(__Pyx_PyLong_DigitCount(x) > 1);
20114
+ switch (__Pyx_PyLong_DigitCount(x)) {
20115
+ case 2:
20116
+ if ((8 * sizeof(size_t) > 1 * PyLong_SHIFT)) {
20117
+ if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
20118
+ __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20119
+ } else if ((8 * sizeof(size_t) >= 2 * PyLong_SHIFT)) {
20120
+ return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
20095
20121
  }
20096
- break;
20097
- case 3:
20098
- if ((8 * sizeof(size_t) > 2 * PyLong_SHIFT)) {
20099
- if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
20100
- __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20101
- } else if ((8 * sizeof(size_t) >= 3 * PyLong_SHIFT)) {
20102
- return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
20103
- }
20122
+ }
20123
+ break;
20124
+ case 3:
20125
+ if ((8 * sizeof(size_t) > 2 * PyLong_SHIFT)) {
20126
+ if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
20127
+ __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20128
+ } else if ((8 * sizeof(size_t) >= 3 * PyLong_SHIFT)) {
20129
+ return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
20104
20130
  }
20105
- break;
20106
- case 4:
20107
- if ((8 * sizeof(size_t) > 3 * PyLong_SHIFT)) {
20108
- if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
20109
- __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20110
- } else if ((8 * sizeof(size_t) >= 4 * PyLong_SHIFT)) {
20111
- return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
20112
- }
20131
+ }
20132
+ break;
20133
+ case 4:
20134
+ if ((8 * sizeof(size_t) > 3 * PyLong_SHIFT)) {
20135
+ if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
20136
+ __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20137
+ } else if ((8 * sizeof(size_t) >= 4 * PyLong_SHIFT)) {
20138
+ return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
20113
20139
  }
20114
- break;
20115
- }
20140
+ }
20141
+ break;
20116
20142
  }
20143
+ }
20117
20144
  #endif
20118
20145
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
20119
- if (unlikely(Py_SIZE(x) < 0)) {
20120
- goto raise_neg_overflow;
20121
- }
20146
+ if (unlikely(Py_SIZE(x) < 0)) {
20147
+ goto raise_neg_overflow;
20148
+ }
20122
20149
  #else
20123
- {
20124
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
20125
- if (unlikely(result < 0))
20126
- return (size_t) -1;
20127
- if (unlikely(result == 1))
20128
- goto raise_neg_overflow;
20129
- }
20150
+ {
20151
+ int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
20152
+ if (unlikely(result < 0))
20153
+ return (size_t) -1;
20154
+ if (unlikely(result == 1))
20155
+ goto raise_neg_overflow;
20156
+ }
20130
20157
  #endif
20131
- if ((sizeof(size_t) <= sizeof(unsigned long))) {
20132
- __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
20158
+ if ((sizeof(size_t) <= sizeof(unsigned long))) {
20159
+ __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
20133
20160
  #ifdef HAVE_LONG_LONG
20134
- } else if ((sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG))) {
20135
- __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
20161
+ } else if ((sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG))) {
20162
+ __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
20136
20163
  #endif
20137
- }
20138
- } else {
20164
+ }
20165
+ } else {
20139
20166
  #if CYTHON_USE_PYLONG_INTERNALS
20140
- if (__Pyx_PyLong_IsCompact(x)) {
20141
- __PYX_VERIFY_RETURN_INT(size_t, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
20142
- } else {
20143
- const digit* digits = __Pyx_PyLong_Digits(x);
20144
- assert(__Pyx_PyLong_DigitCount(x) > 1);
20145
- switch (__Pyx_PyLong_SignedDigitCount(x)) {
20146
- case -2:
20147
- if ((8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT)) {
20148
- if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
20149
- __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20150
- } else if ((8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT)) {
20151
- return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
20152
- }
20167
+ if (__Pyx_PyLong_IsCompact(x)) {
20168
+ __PYX_VERIFY_RETURN_INT(size_t, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
20169
+ } else {
20170
+ const digit* digits = __Pyx_PyLong_Digits(x);
20171
+ assert(__Pyx_PyLong_DigitCount(x) > 1);
20172
+ switch (__Pyx_PyLong_SignedDigitCount(x)) {
20173
+ case -2:
20174
+ if ((8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT)) {
20175
+ if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
20176
+ __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20177
+ } else if ((8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT)) {
20178
+ return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
20153
20179
  }
20154
- break;
20155
- case 2:
20156
- if ((8 * sizeof(size_t) > 1 * PyLong_SHIFT)) {
20157
- if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
20158
- __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20159
- } else if ((8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT)) {
20160
- return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
20161
- }
20180
+ }
20181
+ break;
20182
+ case 2:
20183
+ if ((8 * sizeof(size_t) > 1 * PyLong_SHIFT)) {
20184
+ if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
20185
+ __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20186
+ } else if ((8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT)) {
20187
+ return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
20162
20188
  }
20163
- break;
20164
- case -3:
20165
- if ((8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT)) {
20166
- if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
20167
- __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20168
- } else if ((8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT)) {
20169
- return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
20170
- }
20189
+ }
20190
+ break;
20191
+ case -3:
20192
+ if ((8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT)) {
20193
+ if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
20194
+ __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20195
+ } else if ((8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT)) {
20196
+ return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
20171
20197
  }
20172
- break;
20173
- case 3:
20174
- if ((8 * sizeof(size_t) > 2 * PyLong_SHIFT)) {
20175
- if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
20176
- __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20177
- } else if ((8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT)) {
20178
- return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
20179
- }
20198
+ }
20199
+ break;
20200
+ case 3:
20201
+ if ((8 * sizeof(size_t) > 2 * PyLong_SHIFT)) {
20202
+ if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
20203
+ __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20204
+ } else if ((8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT)) {
20205
+ return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
20180
20206
  }
20181
- break;
20182
- case -4:
20183
- if ((8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT)) {
20184
- if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
20185
- __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20186
- } else if ((8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT)) {
20187
- return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
20188
- }
20207
+ }
20208
+ break;
20209
+ case -4:
20210
+ if ((8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT)) {
20211
+ if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
20212
+ __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20213
+ } else if ((8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT)) {
20214
+ return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
20189
20215
  }
20190
- break;
20191
- case 4:
20192
- if ((8 * sizeof(size_t) > 3 * PyLong_SHIFT)) {
20193
- if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
20194
- __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20195
- } else if ((8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT)) {
20196
- return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
20197
- }
20216
+ }
20217
+ break;
20218
+ case 4:
20219
+ if ((8 * sizeof(size_t) > 3 * PyLong_SHIFT)) {
20220
+ if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
20221
+ __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20222
+ } else if ((8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT)) {
20223
+ return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
20198
20224
  }
20199
- break;
20200
- }
20225
+ }
20226
+ break;
20201
20227
  }
20228
+ }
20202
20229
  #endif
20203
- if ((sizeof(size_t) <= sizeof(long))) {
20204
- __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
20230
+ if ((sizeof(size_t) <= sizeof(long))) {
20231
+ __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
20205
20232
  #ifdef HAVE_LONG_LONG
20206
- } else if ((sizeof(size_t) <= sizeof(PY_LONG_LONG))) {
20207
- __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
20233
+ } else if ((sizeof(size_t) <= sizeof(PY_LONG_LONG))) {
20234
+ __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
20208
20235
  #endif
20209
- }
20210
20236
  }
20211
- {
20212
- size_t val;
20213
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
20214
- #if PY_MAJOR_VERSION < 3
20215
- if (likely(v) && !PyLong_Check(v)) {
20216
- PyObject *tmp = v;
20217
- v = PyNumber_Long(tmp);
20218
- Py_DECREF(tmp);
20219
- }
20220
- #endif
20221
- if (likely(v)) {
20222
- int ret = -1;
20223
- #if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
20224
- int one = 1; int is_little = (int)*(unsigned char *)&one;
20225
- unsigned char *bytes = (unsigned char *)&val;
20226
- ret = _PyLong_AsByteArray((PyLongObject *)v,
20227
- bytes, sizeof(val),
20228
- is_little, !is_unsigned);
20229
- #else
20230
- PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
20231
- int bits, remaining_bits, is_negative = 0;
20232
- long idigit;
20233
- int chunk_size = (sizeof(long) < 8) ? 30 : 62;
20234
- if (unlikely(!PyLong_CheckExact(v))) {
20235
- PyObject *tmp = v;
20236
- v = PyNumber_Long(v);
20237
- assert(PyLong_CheckExact(v));
20238
- Py_DECREF(tmp);
20239
- if (unlikely(!v)) return (size_t) -1;
20240
- }
20241
- #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
20242
- if (Py_SIZE(x) == 0)
20243
- return (size_t) 0;
20244
- is_negative = Py_SIZE(x) < 0;
20237
+ }
20238
+ {
20239
+ size_t val;
20240
+ int ret = -1;
20241
+ #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
20242
+ Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
20243
+ x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
20244
+ if (unlikely(bytes_copied == -1)) {
20245
+ } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
20246
+ goto raise_overflow;
20247
+ } else {
20248
+ ret = 0;
20249
+ }
20250
+ #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
20251
+ int one = 1; int is_little = (int)*(unsigned char *)&one;
20252
+ unsigned char *bytes = (unsigned char *)&val;
20253
+ ret = _PyLong_AsByteArray((PyLongObject *)x,
20254
+ bytes, sizeof(val),
20255
+ is_little, !is_unsigned);
20245
20256
  #else
20246
- {
20247
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
20248
- if (unlikely(result < 0))
20249
- return (size_t) -1;
20250
- is_negative = result == 1;
20251
- }
20252
- #endif
20253
- if (is_unsigned && unlikely(is_negative)) {
20254
- goto raise_neg_overflow;
20255
- } else if (is_negative) {
20256
- stepval = PyNumber_Invert(v);
20257
- if (unlikely(!stepval))
20258
- return (size_t) -1;
20259
- } else {
20260
- stepval = __Pyx_NewRef(v);
20261
- }
20262
- val = (size_t) 0;
20263
- mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
20264
- shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
20265
- for (bits = 0; bits < (int) sizeof(size_t) * 8 - chunk_size; bits += chunk_size) {
20266
- PyObject *tmp, *digit;
20267
- digit = PyNumber_And(stepval, mask);
20268
- if (unlikely(!digit)) goto done;
20269
- idigit = PyLong_AsLong(digit);
20270
- Py_DECREF(digit);
20271
- if (unlikely(idigit < 0)) goto done;
20272
- tmp = PyNumber_Rshift(stepval, shift);
20273
- if (unlikely(!tmp)) goto done;
20274
- Py_DECREF(stepval); stepval = tmp;
20275
- val |= ((size_t) idigit) << bits;
20276
- #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
20277
- if (Py_SIZE(stepval) == 0)
20278
- goto unpacking_done;
20279
- #endif
20280
- }
20281
- idigit = PyLong_AsLong(stepval);
20282
- if (unlikely(idigit < 0)) goto done;
20283
- remaining_bits = ((int) sizeof(size_t) * 8) - bits - (is_unsigned ? 0 : 1);
20284
- if (unlikely(idigit >= (1L << remaining_bits)))
20285
- goto raise_overflow;
20286
- val |= ((size_t) idigit) << bits;
20287
- #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
20288
- unpacking_done:
20289
- #endif
20290
- if (!is_unsigned) {
20291
- if (unlikely(val & (((size_t) 1) << (sizeof(size_t) * 8 - 1))))
20292
- goto raise_overflow;
20293
- if (is_negative)
20294
- val = ~val;
20295
- }
20296
- ret = 0;
20297
- done:
20298
- Py_XDECREF(shift);
20299
- Py_XDECREF(mask);
20300
- Py_XDECREF(stepval);
20301
- #endif
20257
+ PyObject *v;
20258
+ PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
20259
+ int bits, remaining_bits, is_negative = 0;
20260
+ int chunk_size = (sizeof(long) < 8) ? 30 : 62;
20261
+ if (likely(PyLong_CheckExact(x))) {
20262
+ v = __Pyx_NewRef(x);
20263
+ } else {
20264
+ v = PyNumber_Long(x);
20265
+ if (unlikely(!v)) return (size_t) -1;
20266
+ assert(PyLong_CheckExact(v));
20267
+ }
20268
+ {
20269
+ int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
20270
+ if (unlikely(result < 0)) {
20302
20271
  Py_DECREF(v);
20303
- if (likely(!ret))
20304
- return val;
20272
+ return (size_t) -1;
20305
20273
  }
20306
- return (size_t) -1;
20274
+ is_negative = result == 1;
20307
20275
  }
20308
- } else {
20309
- size_t val;
20310
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
20311
- if (!tmp) return (size_t) -1;
20312
- val = __Pyx_PyInt_As_size_t(tmp);
20313
- Py_DECREF(tmp);
20276
+ if (is_unsigned && unlikely(is_negative)) {
20277
+ Py_DECREF(v);
20278
+ goto raise_neg_overflow;
20279
+ } else if (is_negative) {
20280
+ stepval = PyNumber_Invert(v);
20281
+ Py_DECREF(v);
20282
+ if (unlikely(!stepval))
20283
+ return (size_t) -1;
20284
+ } else {
20285
+ stepval = v;
20286
+ }
20287
+ v = NULL;
20288
+ val = (size_t) 0;
20289
+ mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
20290
+ shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
20291
+ for (bits = 0; bits < (int) sizeof(size_t) * 8 - chunk_size; bits += chunk_size) {
20292
+ PyObject *tmp, *digit;
20293
+ long idigit;
20294
+ digit = PyNumber_And(stepval, mask);
20295
+ if (unlikely(!digit)) goto done;
20296
+ idigit = PyLong_AsLong(digit);
20297
+ Py_DECREF(digit);
20298
+ if (unlikely(idigit < 0)) goto done;
20299
+ val |= ((size_t) idigit) << bits;
20300
+ tmp = PyNumber_Rshift(stepval, shift);
20301
+ if (unlikely(!tmp)) goto done;
20302
+ Py_DECREF(stepval); stepval = tmp;
20303
+ }
20304
+ Py_DECREF(shift); shift = NULL;
20305
+ Py_DECREF(mask); mask = NULL;
20306
+ {
20307
+ long idigit = PyLong_AsLong(stepval);
20308
+ if (unlikely(idigit < 0)) goto done;
20309
+ remaining_bits = ((int) sizeof(size_t) * 8) - bits - (is_unsigned ? 0 : 1);
20310
+ if (unlikely(idigit >= (1L << remaining_bits)))
20311
+ goto raise_overflow;
20312
+ val |= ((size_t) idigit) << bits;
20313
+ }
20314
+ if (!is_unsigned) {
20315
+ if (unlikely(val & (((size_t) 1) << (sizeof(size_t) * 8 - 1))))
20316
+ goto raise_overflow;
20317
+ if (is_negative)
20318
+ val = ~val;
20319
+ }
20320
+ ret = 0;
20321
+ done:
20322
+ Py_XDECREF(shift);
20323
+ Py_XDECREF(mask);
20324
+ Py_XDECREF(stepval);
20325
+ #endif
20326
+ if (unlikely(ret))
20327
+ return (size_t) -1;
20314
20328
  return val;
20315
20329
  }
20316
20330
  raise_overflow:
@@ -20361,245 +20375,239 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
20361
20375
  }
20362
20376
  return (long) val;
20363
20377
  }
20364
- } else
20378
+ }
20365
20379
  #endif
20366
- if (likely(PyLong_Check(x))) {
20367
- if (is_unsigned) {
20380
+ if (unlikely(!PyLong_Check(x))) {
20381
+ long val;
20382
+ PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
20383
+ if (!tmp) return (long) -1;
20384
+ val = __Pyx_PyInt_As_long(tmp);
20385
+ Py_DECREF(tmp);
20386
+ return val;
20387
+ }
20388
+ if (is_unsigned) {
20368
20389
  #if CYTHON_USE_PYLONG_INTERNALS
20369
- if (unlikely(__Pyx_PyLong_IsNeg(x))) {
20370
- goto raise_neg_overflow;
20371
- } else if (__Pyx_PyLong_IsCompact(x)) {
20372
- __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
20373
- } else {
20374
- const digit* digits = __Pyx_PyLong_Digits(x);
20375
- assert(__Pyx_PyLong_DigitCount(x) > 1);
20376
- switch (__Pyx_PyLong_DigitCount(x)) {
20377
- case 2:
20378
- if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
20379
- if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
20380
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20381
- } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) {
20382
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
20383
- }
20390
+ if (unlikely(__Pyx_PyLong_IsNeg(x))) {
20391
+ goto raise_neg_overflow;
20392
+ } else if (__Pyx_PyLong_IsCompact(x)) {
20393
+ __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
20394
+ } else {
20395
+ const digit* digits = __Pyx_PyLong_Digits(x);
20396
+ assert(__Pyx_PyLong_DigitCount(x) > 1);
20397
+ switch (__Pyx_PyLong_DigitCount(x)) {
20398
+ case 2:
20399
+ if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
20400
+ if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
20401
+ __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20402
+ } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) {
20403
+ return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
20384
20404
  }
20385
- break;
20386
- case 3:
20387
- if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
20388
- if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
20389
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20390
- } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) {
20391
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
20392
- }
20405
+ }
20406
+ break;
20407
+ case 3:
20408
+ if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
20409
+ if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
20410
+ __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20411
+ } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) {
20412
+ return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
20393
20413
  }
20394
- break;
20395
- case 4:
20396
- if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
20397
- if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
20398
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20399
- } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) {
20400
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
20401
- }
20414
+ }
20415
+ break;
20416
+ case 4:
20417
+ if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
20418
+ if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
20419
+ __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20420
+ } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) {
20421
+ return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
20402
20422
  }
20403
- break;
20404
- }
20423
+ }
20424
+ break;
20405
20425
  }
20426
+ }
20406
20427
  #endif
20407
20428
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
20408
- if (unlikely(Py_SIZE(x) < 0)) {
20409
- goto raise_neg_overflow;
20410
- }
20429
+ if (unlikely(Py_SIZE(x) < 0)) {
20430
+ goto raise_neg_overflow;
20431
+ }
20411
20432
  #else
20412
- {
20413
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
20414
- if (unlikely(result < 0))
20415
- return (long) -1;
20416
- if (unlikely(result == 1))
20417
- goto raise_neg_overflow;
20418
- }
20433
+ {
20434
+ int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
20435
+ if (unlikely(result < 0))
20436
+ return (long) -1;
20437
+ if (unlikely(result == 1))
20438
+ goto raise_neg_overflow;
20439
+ }
20419
20440
  #endif
20420
- if ((sizeof(long) <= sizeof(unsigned long))) {
20421
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
20441
+ if ((sizeof(long) <= sizeof(unsigned long))) {
20442
+ __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
20422
20443
  #ifdef HAVE_LONG_LONG
20423
- } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) {
20424
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
20444
+ } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) {
20445
+ __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
20425
20446
  #endif
20426
- }
20427
- } else {
20447
+ }
20448
+ } else {
20428
20449
  #if CYTHON_USE_PYLONG_INTERNALS
20429
- if (__Pyx_PyLong_IsCompact(x)) {
20430
- __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
20431
- } else {
20432
- const digit* digits = __Pyx_PyLong_Digits(x);
20433
- assert(__Pyx_PyLong_DigitCount(x) > 1);
20434
- switch (__Pyx_PyLong_SignedDigitCount(x)) {
20435
- case -2:
20436
- if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) {
20437
- if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
20438
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20439
- } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
20440
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20441
- }
20450
+ if (__Pyx_PyLong_IsCompact(x)) {
20451
+ __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
20452
+ } else {
20453
+ const digit* digits = __Pyx_PyLong_Digits(x);
20454
+ assert(__Pyx_PyLong_DigitCount(x) > 1);
20455
+ switch (__Pyx_PyLong_SignedDigitCount(x)) {
20456
+ case -2:
20457
+ if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) {
20458
+ if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
20459
+ __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20460
+ } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
20461
+ return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20442
20462
  }
20443
- break;
20444
- case 2:
20445
- if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
20446
- if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
20447
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20448
- } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
20449
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20450
- }
20463
+ }
20464
+ break;
20465
+ case 2:
20466
+ if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
20467
+ if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
20468
+ __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20469
+ } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
20470
+ return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20451
20471
  }
20452
- break;
20453
- case -3:
20454
- if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
20455
- if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
20456
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20457
- } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
20458
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20459
- }
20472
+ }
20473
+ break;
20474
+ case -3:
20475
+ if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
20476
+ if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
20477
+ __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20478
+ } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
20479
+ return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20460
20480
  }
20461
- break;
20462
- case 3:
20463
- if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
20464
- if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
20465
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20466
- } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
20467
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20468
- }
20481
+ }
20482
+ break;
20483
+ case 3:
20484
+ if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
20485
+ if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
20486
+ __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20487
+ } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
20488
+ return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20469
20489
  }
20470
- break;
20471
- case -4:
20472
- if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
20473
- if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
20474
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20475
- } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
20476
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20477
- }
20490
+ }
20491
+ break;
20492
+ case -4:
20493
+ if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
20494
+ if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
20495
+ __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20496
+ } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
20497
+ return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20478
20498
  }
20479
- break;
20480
- case 4:
20481
- if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
20482
- if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
20483
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20484
- } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
20485
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20486
- }
20499
+ }
20500
+ break;
20501
+ case 4:
20502
+ if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
20503
+ if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
20504
+ __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20505
+ } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
20506
+ return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20487
20507
  }
20488
- break;
20489
- }
20508
+ }
20509
+ break;
20490
20510
  }
20511
+ }
20491
20512
  #endif
20492
- if ((sizeof(long) <= sizeof(long))) {
20493
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
20513
+ if ((sizeof(long) <= sizeof(long))) {
20514
+ __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
20494
20515
  #ifdef HAVE_LONG_LONG
20495
- } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) {
20496
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
20516
+ } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) {
20517
+ __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
20497
20518
  #endif
20498
- }
20499
20519
  }
20500
- {
20501
- long val;
20502
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
20503
- #if PY_MAJOR_VERSION < 3
20504
- if (likely(v) && !PyLong_Check(v)) {
20505
- PyObject *tmp = v;
20506
- v = PyNumber_Long(tmp);
20507
- Py_DECREF(tmp);
20508
- }
20509
- #endif
20510
- if (likely(v)) {
20511
- int ret = -1;
20512
- #if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
20513
- int one = 1; int is_little = (int)*(unsigned char *)&one;
20514
- unsigned char *bytes = (unsigned char *)&val;
20515
- ret = _PyLong_AsByteArray((PyLongObject *)v,
20516
- bytes, sizeof(val),
20517
- is_little, !is_unsigned);
20518
- #else
20519
- PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
20520
- int bits, remaining_bits, is_negative = 0;
20521
- long idigit;
20522
- int chunk_size = (sizeof(long) < 8) ? 30 : 62;
20523
- if (unlikely(!PyLong_CheckExact(v))) {
20524
- PyObject *tmp = v;
20525
- v = PyNumber_Long(v);
20526
- assert(PyLong_CheckExact(v));
20527
- Py_DECREF(tmp);
20528
- if (unlikely(!v)) return (long) -1;
20529
- }
20530
- #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
20531
- if (Py_SIZE(x) == 0)
20532
- return (long) 0;
20533
- is_negative = Py_SIZE(x) < 0;
20520
+ }
20521
+ {
20522
+ long val;
20523
+ int ret = -1;
20524
+ #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
20525
+ Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
20526
+ x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
20527
+ if (unlikely(bytes_copied == -1)) {
20528
+ } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
20529
+ goto raise_overflow;
20530
+ } else {
20531
+ ret = 0;
20532
+ }
20533
+ #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
20534
+ int one = 1; int is_little = (int)*(unsigned char *)&one;
20535
+ unsigned char *bytes = (unsigned char *)&val;
20536
+ ret = _PyLong_AsByteArray((PyLongObject *)x,
20537
+ bytes, sizeof(val),
20538
+ is_little, !is_unsigned);
20534
20539
  #else
20535
- {
20536
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
20537
- if (unlikely(result < 0))
20538
- return (long) -1;
20539
- is_negative = result == 1;
20540
- }
20541
- #endif
20542
- if (is_unsigned && unlikely(is_negative)) {
20543
- goto raise_neg_overflow;
20544
- } else if (is_negative) {
20545
- stepval = PyNumber_Invert(v);
20546
- if (unlikely(!stepval))
20547
- return (long) -1;
20548
- } else {
20549
- stepval = __Pyx_NewRef(v);
20550
- }
20551
- val = (long) 0;
20552
- mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
20553
- shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
20554
- for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
20555
- PyObject *tmp, *digit;
20556
- digit = PyNumber_And(stepval, mask);
20557
- if (unlikely(!digit)) goto done;
20558
- idigit = PyLong_AsLong(digit);
20559
- Py_DECREF(digit);
20560
- if (unlikely(idigit < 0)) goto done;
20561
- tmp = PyNumber_Rshift(stepval, shift);
20562
- if (unlikely(!tmp)) goto done;
20563
- Py_DECREF(stepval); stepval = tmp;
20564
- val |= ((long) idigit) << bits;
20565
- #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
20566
- if (Py_SIZE(stepval) == 0)
20567
- goto unpacking_done;
20568
- #endif
20569
- }
20570
- idigit = PyLong_AsLong(stepval);
20571
- if (unlikely(idigit < 0)) goto done;
20572
- remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
20573
- if (unlikely(idigit >= (1L << remaining_bits)))
20574
- goto raise_overflow;
20575
- val |= ((long) idigit) << bits;
20576
- #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
20577
- unpacking_done:
20578
- #endif
20579
- if (!is_unsigned) {
20580
- if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
20581
- goto raise_overflow;
20582
- if (is_negative)
20583
- val = ~val;
20584
- }
20585
- ret = 0;
20586
- done:
20587
- Py_XDECREF(shift);
20588
- Py_XDECREF(mask);
20589
- Py_XDECREF(stepval);
20590
- #endif
20540
+ PyObject *v;
20541
+ PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
20542
+ int bits, remaining_bits, is_negative = 0;
20543
+ int chunk_size = (sizeof(long) < 8) ? 30 : 62;
20544
+ if (likely(PyLong_CheckExact(x))) {
20545
+ v = __Pyx_NewRef(x);
20546
+ } else {
20547
+ v = PyNumber_Long(x);
20548
+ if (unlikely(!v)) return (long) -1;
20549
+ assert(PyLong_CheckExact(v));
20550
+ }
20551
+ {
20552
+ int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
20553
+ if (unlikely(result < 0)) {
20591
20554
  Py_DECREF(v);
20592
- if (likely(!ret))
20593
- return val;
20555
+ return (long) -1;
20594
20556
  }
20595
- return (long) -1;
20557
+ is_negative = result == 1;
20596
20558
  }
20597
- } else {
20598
- long val;
20599
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
20600
- if (!tmp) return (long) -1;
20601
- val = __Pyx_PyInt_As_long(tmp);
20602
- Py_DECREF(tmp);
20559
+ if (is_unsigned && unlikely(is_negative)) {
20560
+ Py_DECREF(v);
20561
+ goto raise_neg_overflow;
20562
+ } else if (is_negative) {
20563
+ stepval = PyNumber_Invert(v);
20564
+ Py_DECREF(v);
20565
+ if (unlikely(!stepval))
20566
+ return (long) -1;
20567
+ } else {
20568
+ stepval = v;
20569
+ }
20570
+ v = NULL;
20571
+ val = (long) 0;
20572
+ mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
20573
+ shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
20574
+ for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
20575
+ PyObject *tmp, *digit;
20576
+ long idigit;
20577
+ digit = PyNumber_And(stepval, mask);
20578
+ if (unlikely(!digit)) goto done;
20579
+ idigit = PyLong_AsLong(digit);
20580
+ Py_DECREF(digit);
20581
+ if (unlikely(idigit < 0)) goto done;
20582
+ val |= ((long) idigit) << bits;
20583
+ tmp = PyNumber_Rshift(stepval, shift);
20584
+ if (unlikely(!tmp)) goto done;
20585
+ Py_DECREF(stepval); stepval = tmp;
20586
+ }
20587
+ Py_DECREF(shift); shift = NULL;
20588
+ Py_DECREF(mask); mask = NULL;
20589
+ {
20590
+ long idigit = PyLong_AsLong(stepval);
20591
+ if (unlikely(idigit < 0)) goto done;
20592
+ remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
20593
+ if (unlikely(idigit >= (1L << remaining_bits)))
20594
+ goto raise_overflow;
20595
+ val |= ((long) idigit) << bits;
20596
+ }
20597
+ if (!is_unsigned) {
20598
+ if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
20599
+ goto raise_overflow;
20600
+ if (is_negative)
20601
+ val = ~val;
20602
+ }
20603
+ ret = 0;
20604
+ done:
20605
+ Py_XDECREF(shift);
20606
+ Py_XDECREF(mask);
20607
+ Py_XDECREF(stepval);
20608
+ #endif
20609
+ if (unlikely(ret))
20610
+ return (long) -1;
20603
20611
  return val;
20604
20612
  }
20605
20613
  raise_overflow: