scikit-network 0.33.0__cp310-cp310-win_amd64.whl → 0.33.2__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 scikit-network might be problematic. Click here for more details.
- scikit_network-0.33.2.dist-info/METADATA +122 -0
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.2.dist-info}/RECORD +44 -44
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.2.dist-info}/WHEEL +1 -1
- sknetwork/classification/diffusion.py +1 -1
- sknetwork/classification/knn.py +1 -1
- sknetwork/classification/metrics.py +3 -3
- sknetwork/classification/pagerank.py +1 -1
- sknetwork/classification/propagation.py +1 -1
- sknetwork/classification/vote.cp310-win_amd64.pyd +0 -0
- sknetwork/classification/vote.cpp +686 -679
- sknetwork/clustering/leiden_core.cp310-win_amd64.pyd +0 -0
- sknetwork/clustering/leiden_core.cpp +715 -704
- sknetwork/clustering/louvain.py +3 -3
- sknetwork/clustering/louvain_core.cp310-win_amd64.pyd +0 -0
- sknetwork/clustering/louvain_core.cpp +715 -704
- sknetwork/clustering/metrics.py +1 -1
- sknetwork/clustering/tests/test_louvain.py +6 -0
- sknetwork/gnn/base_activation.py +1 -0
- sknetwork/gnn/gnn_classifier.py +1 -1
- sknetwork/hierarchy/metrics.py +3 -3
- sknetwork/hierarchy/paris.cp310-win_amd64.pyd +0 -0
- sknetwork/hierarchy/paris.cpp +1766 -1162
- sknetwork/linalg/diteration.cp310-win_amd64.pyd +0 -0
- sknetwork/linalg/diteration.cpp +686 -679
- sknetwork/linalg/push.cp310-win_amd64.pyd +0 -0
- sknetwork/linalg/push.cpp +1763 -1165
- sknetwork/linalg/sparse_lowrank.py +1 -1
- sknetwork/ranking/betweenness.cp310-win_amd64.pyd +0 -0
- sknetwork/ranking/betweenness.cpp +565 -559
- sknetwork/topology/cliques.cp310-win_amd64.pyd +0 -0
- sknetwork/topology/cliques.cpp +1723 -1122
- sknetwork/topology/core.cp310-win_amd64.pyd +0 -0
- sknetwork/topology/core.cpp +1749 -1151
- sknetwork/topology/cycles.py +2 -2
- sknetwork/topology/minheap.cp310-win_amd64.pyd +0 -0
- sknetwork/topology/minheap.cpp +689 -679
- sknetwork/topology/triangles.cp310-win_amd64.pyd +0 -0
- sknetwork/topology/triangles.cpp +439 -434
- sknetwork/topology/weisfeiler_lehman_core.cp310-win_amd64.pyd +0 -0
- sknetwork/topology/weisfeiler_lehman_core.cpp +686 -679
- sknetwork/visualization/graphs.py +1 -1
- scikit_network-0.33.0.dist-info/METADATA +0 -517
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.2.dist-info/licenses}/AUTHORS.rst +0 -0
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.2.dist-info/licenses}/LICENSE +0 -0
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.2.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated by Cython 3.0.
|
|
1
|
+
/* Generated by Cython 3.0.12 */
|
|
2
2
|
|
|
3
3
|
/* BEGIN: Cython Metadata
|
|
4
4
|
{
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"/d2FH4-"
|
|
9
9
|
],
|
|
10
10
|
"include_dirs": [
|
|
11
|
-
"C:\\Users\\runneradmin\\AppData\\Local\\Temp\\
|
|
11
|
+
"C:\\Users\\runneradmin\\AppData\\Local\\Temp\\pip-build-env-09xj1dam\\overlay\\Lib\\site-packages\\numpy\\_core\\include"
|
|
12
12
|
],
|
|
13
13
|
"language": "c++",
|
|
14
14
|
"name": "sknetwork.clustering.leiden_core",
|
|
@@ -44,10 +44,10 @@ END: Cython Metadata */
|
|
|
44
44
|
#else
|
|
45
45
|
#define __PYX_EXTRA_ABI_MODULE_NAME ""
|
|
46
46
|
#endif
|
|
47
|
-
#define CYTHON_ABI "
|
|
47
|
+
#define CYTHON_ABI "3_0_12" __PYX_EXTRA_ABI_MODULE_NAME
|
|
48
48
|
#define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI
|
|
49
49
|
#define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."
|
|
50
|
-
#define CYTHON_HEX_VERSION
|
|
50
|
+
#define CYTHON_HEX_VERSION 0x03000CF0
|
|
51
51
|
#define CYTHON_FUTURE_DIVISION 1
|
|
52
52
|
#include <stddef.h>
|
|
53
53
|
#ifndef offsetof
|
|
@@ -2051,7 +2051,7 @@ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args,
|
|
|
2051
2051
|
#if !CYTHON_VECTORCALL
|
|
2052
2052
|
#if PY_VERSION_HEX >= 0x03080000
|
|
2053
2053
|
#include "frameobject.h"
|
|
2054
|
-
#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
2054
|
+
#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
|
|
2055
2055
|
#ifndef Py_BUILD_CORE
|
|
2056
2056
|
#define Py_BUILD_CORE 1
|
|
2057
2057
|
#endif
|
|
@@ -2388,11 +2388,7 @@ static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* s
|
|
|
2388
2388
|
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
|
|
2389
2389
|
|
|
2390
2390
|
/* HasAttr.proto */
|
|
2391
|
-
#if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1
|
|
2392
|
-
#define __Pyx_HasAttr(o, n) PyObject_HasAttrWithError(o, n)
|
|
2393
|
-
#else
|
|
2394
2391
|
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
|
|
2395
|
-
#endif
|
|
2396
2392
|
|
|
2397
2393
|
/* PyDictContains.proto */
|
|
2398
2394
|
static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
|
|
@@ -4728,10 +4724,11 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __
|
|
|
4728
4724
|
PyObject *__pyx_t_4 = NULL;
|
|
4729
4725
|
PyObject *__pyx_t_5 = NULL;
|
|
4730
4726
|
PyObject *__pyx_t_6 = NULL;
|
|
4731
|
-
int __pyx_t_7;
|
|
4727
|
+
unsigned int __pyx_t_7;
|
|
4732
4728
|
char *__pyx_t_8;
|
|
4733
|
-
|
|
4734
|
-
|
|
4729
|
+
int __pyx_t_9;
|
|
4730
|
+
Py_ssize_t __pyx_t_10;
|
|
4731
|
+
Py_UCS4 __pyx_t_11;
|
|
4735
4732
|
int __pyx_lineno = 0;
|
|
4736
4733
|
const char *__pyx_filename = NULL;
|
|
4737
4734
|
int __pyx_clineno = 0;
|
|
@@ -4957,7 +4954,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __
|
|
|
4957
4954
|
* if dim <= 0:
|
|
4958
4955
|
* raise ValueError, f"Invalid shape in axis {idx}: {dim}."
|
|
4959
4956
|
*/
|
|
4960
|
-
|
|
4957
|
+
__pyx_t_9 = 0;
|
|
4961
4958
|
__pyx_t_4 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_4);
|
|
4962
4959
|
__pyx_t_1 = 0;
|
|
4963
4960
|
for (;;) {
|
|
@@ -4974,11 +4971,11 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __
|
|
|
4974
4971
|
__pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 159, __pyx_L1_error)
|
|
4975
4972
|
__Pyx_GOTREF(__pyx_t_5);
|
|
4976
4973
|
#endif
|
|
4977
|
-
|
|
4974
|
+
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 159, __pyx_L1_error)
|
|
4978
4975
|
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
|
4979
|
-
__pyx_v_dim =
|
|
4980
|
-
__pyx_v_idx =
|
|
4981
|
-
|
|
4976
|
+
__pyx_v_dim = __pyx_t_10;
|
|
4977
|
+
__pyx_v_idx = __pyx_t_9;
|
|
4978
|
+
__pyx_t_9 = (__pyx_t_9 + 1);
|
|
4982
4979
|
|
|
4983
4980
|
/* "View.MemoryView":160
|
|
4984
4981
|
*
|
|
@@ -4999,33 +4996,33 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __
|
|
|
4999
4996
|
*/
|
|
5000
4997
|
__pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 161, __pyx_L1_error)
|
|
5001
4998
|
__Pyx_GOTREF(__pyx_t_5);
|
|
5002
|
-
|
|
5003
|
-
|
|
4999
|
+
__pyx_t_10 = 0;
|
|
5000
|
+
__pyx_t_11 = 127;
|
|
5004
5001
|
__Pyx_INCREF(__pyx_kp_u_Invalid_shape_in_axis);
|
|
5005
|
-
|
|
5002
|
+
__pyx_t_10 += 22;
|
|
5006
5003
|
__Pyx_GIVEREF(__pyx_kp_u_Invalid_shape_in_axis);
|
|
5007
5004
|
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u_Invalid_shape_in_axis);
|
|
5008
5005
|
__pyx_t_6 = __Pyx_PyUnicode_From_int(__pyx_v_idx, 0, ' ', 'd'); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 161, __pyx_L1_error)
|
|
5009
5006
|
__Pyx_GOTREF(__pyx_t_6);
|
|
5010
|
-
|
|
5007
|
+
__pyx_t_10 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
|
|
5011
5008
|
__Pyx_GIVEREF(__pyx_t_6);
|
|
5012
5009
|
PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
|
|
5013
5010
|
__pyx_t_6 = 0;
|
|
5014
5011
|
__Pyx_INCREF(__pyx_kp_u_);
|
|
5015
|
-
|
|
5012
|
+
__pyx_t_10 += 2;
|
|
5016
5013
|
__Pyx_GIVEREF(__pyx_kp_u_);
|
|
5017
5014
|
PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_kp_u_);
|
|
5018
5015
|
__pyx_t_6 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_v_dim, 0, ' ', 'd'); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 161, __pyx_L1_error)
|
|
5019
5016
|
__Pyx_GOTREF(__pyx_t_6);
|
|
5020
|
-
|
|
5017
|
+
__pyx_t_10 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
|
|
5021
5018
|
__Pyx_GIVEREF(__pyx_t_6);
|
|
5022
5019
|
PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_6);
|
|
5023
5020
|
__pyx_t_6 = 0;
|
|
5024
5021
|
__Pyx_INCREF(__pyx_kp_u__2);
|
|
5025
|
-
|
|
5022
|
+
__pyx_t_10 += 1;
|
|
5026
5023
|
__Pyx_GIVEREF(__pyx_kp_u__2);
|
|
5027
5024
|
PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_kp_u__2);
|
|
5028
|
-
__pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_5, 5,
|
|
5025
|
+
__pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_5, 5, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 161, __pyx_L1_error)
|
|
5029
5026
|
__Pyx_GOTREF(__pyx_t_6);
|
|
5030
5027
|
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
|
5031
5028
|
__Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_6, 0, 0);
|
|
@@ -5209,7 +5206,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __
|
|
|
5209
5206
|
*
|
|
5210
5207
|
* @cname('getbuffer')
|
|
5211
5208
|
*/
|
|
5212
|
-
|
|
5209
|
+
__pyx_t_9 = __pyx_array_allocate_buffer(__pyx_v_self); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 180, __pyx_L1_error)
|
|
5213
5210
|
|
|
5214
5211
|
/* "View.MemoryView":179
|
|
5215
5212
|
* self.dtype_is_object = format == b'O'
|
|
@@ -8364,7 +8361,7 @@ static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setit
|
|
|
8364
8361
|
*
|
|
8365
8362
|
* if have_slices: # <<<<<<<<<<<<<<
|
|
8366
8363
|
* obj = self.is_slice(value)
|
|
8367
|
-
* if obj:
|
|
8364
|
+
* if obj is not None:
|
|
8368
8365
|
*/
|
|
8369
8366
|
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(1, 426, __pyx_L1_error)
|
|
8370
8367
|
if (__pyx_t_4) {
|
|
@@ -8373,7 +8370,7 @@ static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setit
|
|
|
8373
8370
|
*
|
|
8374
8371
|
* if have_slices:
|
|
8375
8372
|
* obj = self.is_slice(value) # <<<<<<<<<<<<<<
|
|
8376
|
-
* if obj:
|
|
8373
|
+
* if obj is not None:
|
|
8377
8374
|
* self.setitem_slice_assignment(self[index], obj)
|
|
8378
8375
|
*/
|
|
8379
8376
|
__pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 427, __pyx_L1_error)
|
|
@@ -8384,16 +8381,16 @@ static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setit
|
|
|
8384
8381
|
/* "View.MemoryView":428
|
|
8385
8382
|
* if have_slices:
|
|
8386
8383
|
* obj = self.is_slice(value)
|
|
8387
|
-
* if obj: # <<<<<<<<<<<<<<
|
|
8384
|
+
* if obj is not None: # <<<<<<<<<<<<<<
|
|
8388
8385
|
* self.setitem_slice_assignment(self[index], obj)
|
|
8389
8386
|
* else:
|
|
8390
8387
|
*/
|
|
8391
|
-
__pyx_t_4 =
|
|
8388
|
+
__pyx_t_4 = (__pyx_v_obj != Py_None);
|
|
8392
8389
|
if (__pyx_t_4) {
|
|
8393
8390
|
|
|
8394
8391
|
/* "View.MemoryView":429
|
|
8395
8392
|
* obj = self.is_slice(value)
|
|
8396
|
-
* if obj:
|
|
8393
|
+
* if obj is not None:
|
|
8397
8394
|
* self.setitem_slice_assignment(self[index], obj) # <<<<<<<<<<<<<<
|
|
8398
8395
|
* else:
|
|
8399
8396
|
* self.setitem_slice_assign_scalar(self[index], value)
|
|
@@ -8408,7 +8405,7 @@ static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setit
|
|
|
8408
8405
|
/* "View.MemoryView":428
|
|
8409
8406
|
* if have_slices:
|
|
8410
8407
|
* obj = self.is_slice(value)
|
|
8411
|
-
* if obj: # <<<<<<<<<<<<<<
|
|
8408
|
+
* if obj is not None: # <<<<<<<<<<<<<<
|
|
8412
8409
|
* self.setitem_slice_assignment(self[index], obj)
|
|
8413
8410
|
* else:
|
|
8414
8411
|
*/
|
|
@@ -8438,7 +8435,7 @@ static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setit
|
|
|
8438
8435
|
*
|
|
8439
8436
|
* if have_slices: # <<<<<<<<<<<<<<
|
|
8440
8437
|
* obj = self.is_slice(value)
|
|
8441
|
-
* if obj:
|
|
8438
|
+
* if obj is not None:
|
|
8442
8439
|
*/
|
|
8443
8440
|
goto __pyx_L4;
|
|
8444
8441
|
}
|
|
@@ -9146,9 +9143,10 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview
|
|
|
9146
9143
|
PyObject *__pyx_t_5 = NULL;
|
|
9147
9144
|
PyObject *__pyx_t_6 = NULL;
|
|
9148
9145
|
PyObject *__pyx_t_7 = NULL;
|
|
9149
|
-
int __pyx_t_8;
|
|
9146
|
+
unsigned int __pyx_t_8;
|
|
9150
9147
|
Py_ssize_t __pyx_t_9;
|
|
9151
9148
|
int __pyx_t_10;
|
|
9149
|
+
int __pyx_t_11;
|
|
9152
9150
|
int __pyx_lineno = 0;
|
|
9153
9151
|
const char *__pyx_filename = NULL;
|
|
9154
9152
|
int __pyx_clineno = 0;
|
|
@@ -9303,11 +9301,11 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview
|
|
|
9303
9301
|
__Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_5, &__pyx_t_6);
|
|
9304
9302
|
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 498, __pyx_L5_except_error)
|
|
9305
9303
|
__Pyx_GOTREF(__pyx_t_7);
|
|
9306
|
-
|
|
9304
|
+
__pyx_t_11 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_7);
|
|
9307
9305
|
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
|
|
9308
9306
|
__Pyx_ErrRestore(__pyx_t_1, __pyx_t_5, __pyx_t_6);
|
|
9309
9307
|
__pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0;
|
|
9310
|
-
if (
|
|
9308
|
+
if (__pyx_t_11) {
|
|
9311
9309
|
__Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
|
|
9312
9310
|
if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(1, 498, __pyx_L5_except_error)
|
|
9313
9311
|
__Pyx_XGOTREF(__pyx_t_6);
|
|
@@ -9392,7 +9390,7 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie
|
|
|
9392
9390
|
PyObject *__pyx_t_3 = NULL;
|
|
9393
9391
|
PyObject *__pyx_t_4 = NULL;
|
|
9394
9392
|
PyObject *__pyx_t_5 = NULL;
|
|
9395
|
-
int __pyx_t_6;
|
|
9393
|
+
unsigned int __pyx_t_6;
|
|
9396
9394
|
Py_ssize_t __pyx_t_7;
|
|
9397
9395
|
PyObject *__pyx_t_8 = NULL;
|
|
9398
9396
|
char *__pyx_t_9;
|
|
@@ -17866,7 +17864,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSE
|
|
|
17866
17864
|
int __pyx_t_2;
|
|
17867
17865
|
PyObject *__pyx_t_3 = NULL;
|
|
17868
17866
|
PyObject *__pyx_t_4 = NULL;
|
|
17869
|
-
int __pyx_t_5;
|
|
17867
|
+
unsigned int __pyx_t_5;
|
|
17870
17868
|
int __pyx_lineno = 0;
|
|
17871
17869
|
const char *__pyx_filename = NULL;
|
|
17872
17870
|
int __pyx_clineno = 0;
|
|
@@ -18048,7 +18046,7 @@ static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__
|
|
|
18048
18046
|
PyObject *__pyx_t_5 = NULL;
|
|
18049
18047
|
PyObject *__pyx_t_6 = NULL;
|
|
18050
18048
|
PyObject *__pyx_t_7 = NULL;
|
|
18051
|
-
int __pyx_t_8;
|
|
18049
|
+
unsigned int __pyx_t_8;
|
|
18052
18050
|
int __pyx_lineno = 0;
|
|
18053
18051
|
const char *__pyx_filename = NULL;
|
|
18054
18052
|
int __pyx_clineno = 0;
|
|
@@ -18365,8 +18363,9 @@ static PyObject *__pyx_pf_9sknetwork_10clustering_11leiden_core_optimize_refine_
|
|
|
18365
18363
|
int __pyx_t_15;
|
|
18366
18364
|
PyObject *__pyx_t_16 = NULL;
|
|
18367
18365
|
PyObject *__pyx_t_17 = NULL;
|
|
18368
|
-
|
|
18369
|
-
|
|
18366
|
+
unsigned int __pyx_t_18;
|
|
18367
|
+
Py_ssize_t __pyx_t_19;
|
|
18368
|
+
int __pyx_t_20;
|
|
18370
18369
|
int __pyx_lineno = 0;
|
|
18371
18370
|
const char *__pyx_filename = NULL;
|
|
18372
18371
|
int __pyx_clineno = 0;
|
|
@@ -18744,7 +18743,7 @@ static PyObject *__pyx_pf_9sknetwork_10clustering_11leiden_core_optimize_refine_
|
|
|
18744
18743
|
__pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
18745
18744
|
__Pyx_GOTREF(__pyx_t_16);
|
|
18746
18745
|
__pyx_t_17 = NULL;
|
|
18747
|
-
|
|
18746
|
+
__pyx_t_18 = 0;
|
|
18748
18747
|
#if CYTHON_UNPACK_METHODS
|
|
18749
18748
|
if (likely(PyMethod_Check(__pyx_t_16))) {
|
|
18750
18749
|
__pyx_t_17 = PyMethod_GET_SELF(__pyx_t_16);
|
|
@@ -18753,13 +18752,13 @@ static PyObject *__pyx_pf_9sknetwork_10clustering_11leiden_core_optimize_refine_
|
|
|
18753
18752
|
__Pyx_INCREF(__pyx_t_17);
|
|
18754
18753
|
__Pyx_INCREF(function);
|
|
18755
18754
|
__Pyx_DECREF_SET(__pyx_t_16, function);
|
|
18756
|
-
|
|
18755
|
+
__pyx_t_18 = 1;
|
|
18757
18756
|
}
|
|
18758
18757
|
}
|
|
18759
18758
|
#endif
|
|
18760
18759
|
{
|
|
18761
18760
|
PyObject *__pyx_callargs[2] = {__pyx_t_17, __pyx_kp_s__9};
|
|
18762
|
-
__pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_16, __pyx_callargs+1-
|
|
18761
|
+
__pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_16, __pyx_callargs+1-__pyx_t_18, 1+__pyx_t_18);
|
|
18763
18762
|
__Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
|
|
18764
18763
|
if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
18765
18764
|
__Pyx_GOTREF(__pyx_t_6);
|
|
@@ -18769,7 +18768,7 @@ static PyObject *__pyx_pf_9sknetwork_10clustering_11leiden_core_optimize_refine_
|
|
|
18769
18768
|
__Pyx_GOTREF(__pyx_t_16);
|
|
18770
18769
|
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
|
18771
18770
|
__pyx_t_6 = NULL;
|
|
18772
|
-
|
|
18771
|
+
__pyx_t_18 = 0;
|
|
18773
18772
|
#if CYTHON_UNPACK_METHODS
|
|
18774
18773
|
if (likely(PyMethod_Check(__pyx_t_16))) {
|
|
18775
18774
|
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_16);
|
|
@@ -18778,13 +18777,13 @@ static PyObject *__pyx_pf_9sknetwork_10clustering_11leiden_core_optimize_refine_
|
|
|
18778
18777
|
__Pyx_INCREF(__pyx_t_6);
|
|
18779
18778
|
__Pyx_INCREF(function);
|
|
18780
18779
|
__Pyx_DECREF_SET(__pyx_t_16, function);
|
|
18781
|
-
|
|
18780
|
+
__pyx_t_18 = 1;
|
|
18782
18781
|
}
|
|
18783
18782
|
}
|
|
18784
18783
|
#endif
|
|
18785
18784
|
{
|
|
18786
18785
|
PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_kp_s__10};
|
|
18787
|
-
__pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_16, __pyx_callargs+1-
|
|
18786
|
+
__pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_16, __pyx_callargs+1-__pyx_t_18, 1+__pyx_t_18);
|
|
18788
18787
|
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
|
|
18789
18788
|
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
18790
18789
|
__Pyx_GOTREF(__pyx_t_1);
|
|
@@ -18793,19 +18792,19 @@ static PyObject *__pyx_pf_9sknetwork_10clustering_11leiden_core_optimize_refine_
|
|
|
18793
18792
|
__pyx_t_16 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
18794
18793
|
__Pyx_GOTREF(__pyx_t_16);
|
|
18795
18794
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
18796
|
-
|
|
18797
|
-
if (unlikely(
|
|
18798
|
-
__Pyx_RaiseNeedMoreValuesError(0+
|
|
18795
|
+
__pyx_t_19 = PyList_GET_SIZE(__pyx_t_16);
|
|
18796
|
+
if (unlikely(__pyx_t_19 < 1)) {
|
|
18797
|
+
__Pyx_RaiseNeedMoreValuesError(0+__pyx_t_19); __PYX_ERR(0, 12, __pyx_L1_error)
|
|
18799
18798
|
}
|
|
18800
18799
|
#if CYTHON_COMPILING_IN_CPYTHON
|
|
18801
|
-
__pyx_t_6 = PyList_GET_ITEM(__pyx_t_16,
|
|
18800
|
+
__pyx_t_6 = PyList_GET_ITEM(__pyx_t_16, __pyx_t_19-1);
|
|
18802
18801
|
((PyVarObject*)__pyx_t_16)->ob_size--;
|
|
18803
18802
|
#else
|
|
18804
|
-
__pyx_t_6 = PySequence_ITEM(__pyx_t_16,
|
|
18803
|
+
__pyx_t_6 = PySequence_ITEM(__pyx_t_16, __pyx_t_19-1);
|
|
18805
18804
|
#endif
|
|
18806
18805
|
__Pyx_GOTREF(__pyx_t_6);
|
|
18807
18806
|
#if !CYTHON_COMPILING_IN_CPYTHON
|
|
18808
|
-
__pyx_t_17 = PySequence_GetSlice(__pyx_t_16, 0,
|
|
18807
|
+
__pyx_t_17 = PySequence_GetSlice(__pyx_t_16, 0, __pyx_t_19-1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
18809
18808
|
__Pyx_GOTREF(__pyx_t_17);
|
|
18810
18809
|
__Pyx_DECREF(__pyx_t_16);
|
|
18811
18810
|
__pyx_t_16 = __pyx_t_17; __pyx_t_17 = NULL;
|
|
@@ -18817,19 +18816,19 @@ static PyObject *__pyx_pf_9sknetwork_10clustering_11leiden_core_optimize_refine_
|
|
|
18817
18816
|
__Pyx_XDECREF_SET(__pyx_v_last_type, __pyx_t_6);
|
|
18818
18817
|
__pyx_t_6 = 0;
|
|
18819
18818
|
__pyx_t_1 = __pyx_v_sig_series; __Pyx_INCREF(__pyx_t_1);
|
|
18820
|
-
|
|
18819
|
+
__pyx_t_19 = 0;
|
|
18821
18820
|
for (;;) {
|
|
18822
18821
|
{
|
|
18823
18822
|
Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
|
|
18824
18823
|
#if !CYTHON_ASSUME_SAFE_MACROS
|
|
18825
18824
|
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
18826
18825
|
#endif
|
|
18827
|
-
if (
|
|
18826
|
+
if (__pyx_t_19 >= __pyx_temp) break;
|
|
18828
18827
|
}
|
|
18829
18828
|
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
|
|
18830
|
-
__pyx_t_6 = PyList_GET_ITEM(__pyx_t_1,
|
|
18829
|
+
__pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_19); __Pyx_INCREF(__pyx_t_6); __pyx_t_19++; if (unlikely((0 < 0))) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
18831
18830
|
#else
|
|
18832
|
-
__pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_1,
|
|
18831
|
+
__pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_19); __pyx_t_19++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
18833
18832
|
__Pyx_GOTREF(__pyx_t_6);
|
|
18834
18833
|
#endif
|
|
18835
18834
|
__Pyx_XDECREF_SET(__pyx_v_sig_type, __pyx_t_6);
|
|
@@ -18939,7 +18938,7 @@ static PyObject *__pyx_pf_9sknetwork_10clustering_11leiden_core_optimize_refine_
|
|
|
18939
18938
|
}
|
|
18940
18939
|
__pyx_t_16 = __Pyx_PyDict_Values(((PyObject*)__pyx_v_sn)); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
18941
18940
|
__Pyx_GOTREF(__pyx_t_16);
|
|
18942
|
-
|
|
18941
|
+
__pyx_t_20 = __Pyx_PyList_Extend(__pyx_v_found_matches, __pyx_t_16); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
18943
18942
|
__Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
|
|
18944
18943
|
}
|
|
18945
18944
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
@@ -18967,7 +18966,7 @@ static PyObject *__pyx_pf_9sknetwork_10clustering_11leiden_core_optimize_refine_
|
|
|
18967
18966
|
}
|
|
18968
18967
|
__pyx_t_16 = __Pyx_PyDict_Values(((PyObject*)__pyx_v_sn)); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
18969
18968
|
__Pyx_GOTREF(__pyx_t_16);
|
|
18970
|
-
|
|
18969
|
+
__pyx_t_20 = __Pyx_PyList_Extend(__pyx_v_found_candidates, __pyx_t_16); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
18971
18970
|
__Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
|
|
18972
18971
|
}
|
|
18973
18972
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
@@ -19000,19 +18999,19 @@ static PyObject *__pyx_pf_9sknetwork_10clustering_11leiden_core_optimize_refine_
|
|
|
19000
18999
|
__PYX_ERR(0, 12, __pyx_L1_error)
|
|
19001
19000
|
}
|
|
19002
19001
|
__pyx_t_1 = __pyx_v_search_list; __Pyx_INCREF(__pyx_t_1);
|
|
19003
|
-
|
|
19002
|
+
__pyx_t_19 = 0;
|
|
19004
19003
|
for (;;) {
|
|
19005
19004
|
{
|
|
19006
19005
|
Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
|
|
19007
19006
|
#if !CYTHON_ASSUME_SAFE_MACROS
|
|
19008
19007
|
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
19009
19008
|
#endif
|
|
19010
|
-
if (
|
|
19009
|
+
if (__pyx_t_19 >= __pyx_temp) break;
|
|
19011
19010
|
}
|
|
19012
19011
|
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
|
|
19013
|
-
__pyx_t_6 = PyList_GET_ITEM(__pyx_t_1,
|
|
19012
|
+
__pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_19); __Pyx_INCREF(__pyx_t_6); __pyx_t_19++; if (unlikely((0 < 0))) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
19014
19013
|
#else
|
|
19015
|
-
__pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_1,
|
|
19014
|
+
__pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_19); __pyx_t_19++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
19016
19015
|
__Pyx_GOTREF(__pyx_t_6);
|
|
19017
19016
|
#endif
|
|
19018
19017
|
__Pyx_XDECREF_SET(__pyx_v_sn, __pyx_t_6);
|
|
@@ -19027,7 +19026,7 @@ static PyObject *__pyx_pf_9sknetwork_10clustering_11leiden_core_optimize_refine_
|
|
|
19027
19026
|
__pyx_t_6 = 0;
|
|
19028
19027
|
__pyx_t_4 = (__pyx_v_type_match != Py_None);
|
|
19029
19028
|
if (__pyx_t_4) {
|
|
19030
|
-
|
|
19029
|
+
__pyx_t_20 = __Pyx_PyList_Append(__pyx_v_found_matches, __pyx_v_type_match); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 12, __pyx_L1_error)
|
|
19031
19030
|
}
|
|
19032
19031
|
}
|
|
19033
19032
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
@@ -21136,6 +21135,9 @@ static PyTypeObject __pyx_type___pyx_array = {
|
|
|
21136
21135
|
#if PY_VERSION_HEX >= 0x030C0000
|
|
21137
21136
|
0, /*tp_watched*/
|
|
21138
21137
|
#endif
|
|
21138
|
+
#if PY_VERSION_HEX >= 0x030d00A4
|
|
21139
|
+
0, /*tp_versions_used*/
|
|
21140
|
+
#endif
|
|
21139
21141
|
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
|
|
21140
21142
|
0, /*tp_pypy_flags*/
|
|
21141
21143
|
#endif
|
|
@@ -21306,6 +21308,9 @@ static PyTypeObject __pyx_type___pyx_MemviewEnum = {
|
|
|
21306
21308
|
#if PY_VERSION_HEX >= 0x030C0000
|
|
21307
21309
|
0, /*tp_watched*/
|
|
21308
21310
|
#endif
|
|
21311
|
+
#if PY_VERSION_HEX >= 0x030d00A4
|
|
21312
|
+
0, /*tp_versions_used*/
|
|
21313
|
+
#endif
|
|
21309
21314
|
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
|
|
21310
21315
|
0, /*tp_pypy_flags*/
|
|
21311
21316
|
#endif
|
|
@@ -21649,6 +21654,9 @@ static PyTypeObject __pyx_type___pyx_memoryview = {
|
|
|
21649
21654
|
#if PY_VERSION_HEX >= 0x030C0000
|
|
21650
21655
|
0, /*tp_watched*/
|
|
21651
21656
|
#endif
|
|
21657
|
+
#if PY_VERSION_HEX >= 0x030d00A4
|
|
21658
|
+
0, /*tp_versions_used*/
|
|
21659
|
+
#endif
|
|
21652
21660
|
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
|
|
21653
21661
|
0, /*tp_pypy_flags*/
|
|
21654
21662
|
#endif
|
|
@@ -21821,6 +21829,9 @@ static PyTypeObject __pyx_type___pyx_memoryviewslice = {
|
|
|
21821
21829
|
#if PY_VERSION_HEX >= 0x030C0000
|
|
21822
21830
|
0, /*tp_watched*/
|
|
21823
21831
|
#endif
|
|
21832
|
+
#if PY_VERSION_HEX >= 0x030d00A4
|
|
21833
|
+
0, /*tp_versions_used*/
|
|
21834
|
+
#endif
|
|
21824
21835
|
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
|
|
21825
21836
|
0, /*tp_pypy_flags*/
|
|
21826
21837
|
#endif
|
|
@@ -25767,7 +25778,6 @@ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
|
|
|
25767
25778
|
}
|
|
25768
25779
|
|
|
25769
25780
|
/* HasAttr */
|
|
25770
|
-
#if __PYX_LIMITED_VERSION_HEX < 0x030d00A1
|
|
25771
25781
|
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
|
|
25772
25782
|
PyObject *r;
|
|
25773
25783
|
if (unlikely(!__Pyx_PyBaseString_Check(n))) {
|
|
@@ -25784,7 +25794,6 @@ static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
|
|
|
25784
25794
|
return 1;
|
|
25785
25795
|
}
|
|
25786
25796
|
}
|
|
25787
|
-
#endif
|
|
25788
25797
|
|
|
25789
25798
|
/* DictGetItem */
|
|
25790
25799
|
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
|
|
@@ -28283,6 +28292,9 @@ static PyTypeObject __pyx_CyFunctionType_type = {
|
|
|
28283
28292
|
#if PY_VERSION_HEX >= 0x030C0000
|
|
28284
28293
|
0,
|
|
28285
28294
|
#endif
|
|
28295
|
+
#if PY_VERSION_HEX >= 0x030d00A4
|
|
28296
|
+
0,
|
|
28297
|
+
#endif
|
|
28286
28298
|
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
|
|
28287
28299
|
0,
|
|
28288
28300
|
#endif
|
|
@@ -28660,6 +28672,9 @@ static PyTypeObject __pyx_FusedFunctionType_type = {
|
|
|
28660
28672
|
#if PY_VERSION_HEX >= 0x030C0000
|
|
28661
28673
|
0,
|
|
28662
28674
|
#endif
|
|
28675
|
+
#if PY_VERSION_HEX >= 0x030d00A4
|
|
28676
|
+
0,
|
|
28677
|
+
#endif
|
|
28663
28678
|
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
|
|
28664
28679
|
0,
|
|
28665
28680
|
#endif
|
|
@@ -28813,7 +28828,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
|
|
|
28813
28828
|
#include "compile.h"
|
|
28814
28829
|
#include "frameobject.h"
|
|
28815
28830
|
#include "traceback.h"
|
|
28816
|
-
#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
28831
|
+
#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
|
|
28817
28832
|
#ifndef Py_BUILD_CORE
|
|
28818
28833
|
#define Py_BUILD_CORE 1
|
|
28819
28834
|
#endif
|
|
@@ -30247,12 +30262,19 @@ static CYTHON_INLINE void __Pyx_XCLEAR_MEMVIEW(__Pyx_memviewslice *memslice,
|
|
|
30247
30262
|
}
|
|
30248
30263
|
}
|
|
30249
30264
|
{
|
|
30250
|
-
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
30251
30265
|
unsigned char *bytes = (unsigned char *)&value;
|
|
30252
|
-
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX
|
|
30266
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
|
|
30267
|
+
if (is_unsigned) {
|
|
30268
|
+
return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
|
|
30269
|
+
} else {
|
|
30270
|
+
return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
|
|
30271
|
+
}
|
|
30272
|
+
#elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
|
|
30273
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
30253
30274
|
return _PyLong_FromByteArray(bytes, sizeof(long),
|
|
30254
30275
|
little, !is_unsigned);
|
|
30255
30276
|
#else
|
|
30277
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
30256
30278
|
PyObject *from_bytes, *result = NULL;
|
|
30257
30279
|
PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL;
|
|
30258
30280
|
from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
|
|
@@ -30311,12 +30333,19 @@ static CYTHON_INLINE void __Pyx_XCLEAR_MEMVIEW(__Pyx_memviewslice *memslice,
|
|
|
30311
30333
|
}
|
|
30312
30334
|
}
|
|
30313
30335
|
{
|
|
30314
|
-
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
30315
30336
|
unsigned char *bytes = (unsigned char *)&value;
|
|
30316
|
-
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX
|
|
30337
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
|
|
30338
|
+
if (is_unsigned) {
|
|
30339
|
+
return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
|
|
30340
|
+
} else {
|
|
30341
|
+
return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
|
|
30342
|
+
}
|
|
30343
|
+
#elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
|
|
30344
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
30317
30345
|
return _PyLong_FromByteArray(bytes, sizeof(int),
|
|
30318
30346
|
little, !is_unsigned);
|
|
30319
30347
|
#else
|
|
30348
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
30320
30349
|
PyObject *from_bytes, *result = NULL;
|
|
30321
30350
|
PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL;
|
|
30322
30351
|
from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
|
|
@@ -30366,245 +30395,239 @@ static CYTHON_INLINE void __Pyx_XCLEAR_MEMVIEW(__Pyx_memviewslice *memslice,
|
|
|
30366
30395
|
}
|
|
30367
30396
|
return (int) val;
|
|
30368
30397
|
}
|
|
30369
|
-
}
|
|
30398
|
+
}
|
|
30370
30399
|
#endif
|
|
30371
|
-
if (
|
|
30372
|
-
|
|
30400
|
+
if (unlikely(!PyLong_Check(x))) {
|
|
30401
|
+
int val;
|
|
30402
|
+
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
|
|
30403
|
+
if (!tmp) return (int) -1;
|
|
30404
|
+
val = __Pyx_PyInt_As_int(tmp);
|
|
30405
|
+
Py_DECREF(tmp);
|
|
30406
|
+
return val;
|
|
30407
|
+
}
|
|
30408
|
+
if (is_unsigned) {
|
|
30373
30409
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
30374
|
-
|
|
30375
|
-
|
|
30376
|
-
|
|
30377
|
-
|
|
30378
|
-
|
|
30379
|
-
|
|
30380
|
-
|
|
30381
|
-
|
|
30382
|
-
|
|
30383
|
-
|
|
30384
|
-
|
|
30385
|
-
|
|
30386
|
-
|
|
30387
|
-
|
|
30388
|
-
}
|
|
30410
|
+
if (unlikely(__Pyx_PyLong_IsNeg(x))) {
|
|
30411
|
+
goto raise_neg_overflow;
|
|
30412
|
+
} else if (__Pyx_PyLong_IsCompact(x)) {
|
|
30413
|
+
__PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
|
|
30414
|
+
} else {
|
|
30415
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
30416
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
30417
|
+
switch (__Pyx_PyLong_DigitCount(x)) {
|
|
30418
|
+
case 2:
|
|
30419
|
+
if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
|
|
30420
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
30421
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30422
|
+
} else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) {
|
|
30423
|
+
return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
|
|
30389
30424
|
}
|
|
30390
|
-
|
|
30391
|
-
|
|
30392
|
-
|
|
30393
|
-
|
|
30394
|
-
|
|
30395
|
-
|
|
30396
|
-
|
|
30397
|
-
|
|
30425
|
+
}
|
|
30426
|
+
break;
|
|
30427
|
+
case 3:
|
|
30428
|
+
if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
|
|
30429
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
30430
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30431
|
+
} else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) {
|
|
30432
|
+
return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
|
|
30398
30433
|
}
|
|
30399
|
-
|
|
30400
|
-
|
|
30401
|
-
|
|
30402
|
-
|
|
30403
|
-
|
|
30404
|
-
|
|
30405
|
-
|
|
30406
|
-
|
|
30434
|
+
}
|
|
30435
|
+
break;
|
|
30436
|
+
case 4:
|
|
30437
|
+
if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
|
|
30438
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
30439
|
+
__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])))
|
|
30440
|
+
} else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) {
|
|
30441
|
+
return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
|
|
30407
30442
|
}
|
|
30408
|
-
|
|
30409
|
-
|
|
30443
|
+
}
|
|
30444
|
+
break;
|
|
30410
30445
|
}
|
|
30446
|
+
}
|
|
30411
30447
|
#endif
|
|
30412
30448
|
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
|
|
30413
|
-
|
|
30414
|
-
|
|
30415
|
-
|
|
30449
|
+
if (unlikely(Py_SIZE(x) < 0)) {
|
|
30450
|
+
goto raise_neg_overflow;
|
|
30451
|
+
}
|
|
30416
30452
|
#else
|
|
30417
|
-
|
|
30418
|
-
|
|
30419
|
-
|
|
30420
|
-
|
|
30421
|
-
|
|
30422
|
-
|
|
30423
|
-
|
|
30453
|
+
{
|
|
30454
|
+
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
30455
|
+
if (unlikely(result < 0))
|
|
30456
|
+
return (int) -1;
|
|
30457
|
+
if (unlikely(result == 1))
|
|
30458
|
+
goto raise_neg_overflow;
|
|
30459
|
+
}
|
|
30424
30460
|
#endif
|
|
30425
|
-
|
|
30426
|
-
|
|
30461
|
+
if ((sizeof(int) <= sizeof(unsigned long))) {
|
|
30462
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
|
|
30427
30463
|
#ifdef HAVE_LONG_LONG
|
|
30428
|
-
|
|
30429
|
-
|
|
30464
|
+
} else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) {
|
|
30465
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
|
|
30430
30466
|
#endif
|
|
30431
|
-
|
|
30432
|
-
|
|
30467
|
+
}
|
|
30468
|
+
} else {
|
|
30433
30469
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
30434
|
-
|
|
30435
|
-
|
|
30436
|
-
|
|
30437
|
-
|
|
30438
|
-
|
|
30439
|
-
|
|
30440
|
-
|
|
30441
|
-
|
|
30442
|
-
|
|
30443
|
-
|
|
30444
|
-
|
|
30445
|
-
|
|
30446
|
-
}
|
|
30470
|
+
if (__Pyx_PyLong_IsCompact(x)) {
|
|
30471
|
+
__PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
|
|
30472
|
+
} else {
|
|
30473
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
30474
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
30475
|
+
switch (__Pyx_PyLong_SignedDigitCount(x)) {
|
|
30476
|
+
case -2:
|
|
30477
|
+
if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) {
|
|
30478
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
30479
|
+
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30480
|
+
} else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
|
|
30481
|
+
return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
30447
30482
|
}
|
|
30448
|
-
|
|
30449
|
-
|
|
30450
|
-
|
|
30451
|
-
|
|
30452
|
-
|
|
30453
|
-
|
|
30454
|
-
|
|
30455
|
-
|
|
30483
|
+
}
|
|
30484
|
+
break;
|
|
30485
|
+
case 2:
|
|
30486
|
+
if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
|
|
30487
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
30488
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30489
|
+
} else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
|
|
30490
|
+
return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
30456
30491
|
}
|
|
30457
|
-
|
|
30458
|
-
|
|
30459
|
-
|
|
30460
|
-
|
|
30461
|
-
|
|
30462
|
-
|
|
30463
|
-
|
|
30464
|
-
|
|
30492
|
+
}
|
|
30493
|
+
break;
|
|
30494
|
+
case -3:
|
|
30495
|
+
if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
|
|
30496
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
30497
|
+
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30498
|
+
} else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
|
|
30499
|
+
return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
30465
30500
|
}
|
|
30466
|
-
|
|
30467
|
-
|
|
30468
|
-
|
|
30469
|
-
|
|
30470
|
-
|
|
30471
|
-
|
|
30472
|
-
|
|
30473
|
-
|
|
30501
|
+
}
|
|
30502
|
+
break;
|
|
30503
|
+
case 3:
|
|
30504
|
+
if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
|
|
30505
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
30506
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30507
|
+
} else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
|
|
30508
|
+
return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
30474
30509
|
}
|
|
30475
|
-
|
|
30476
|
-
|
|
30477
|
-
|
|
30478
|
-
|
|
30479
|
-
|
|
30480
|
-
|
|
30481
|
-
|
|
30482
|
-
|
|
30510
|
+
}
|
|
30511
|
+
break;
|
|
30512
|
+
case -4:
|
|
30513
|
+
if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
|
|
30514
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
30515
|
+
__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])))
|
|
30516
|
+
} else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
|
|
30517
|
+
return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
30483
30518
|
}
|
|
30484
|
-
|
|
30485
|
-
|
|
30486
|
-
|
|
30487
|
-
|
|
30488
|
-
|
|
30489
|
-
|
|
30490
|
-
|
|
30491
|
-
|
|
30519
|
+
}
|
|
30520
|
+
break;
|
|
30521
|
+
case 4:
|
|
30522
|
+
if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
|
|
30523
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
30524
|
+
__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])))
|
|
30525
|
+
} else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
|
|
30526
|
+
return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
30492
30527
|
}
|
|
30493
|
-
|
|
30494
|
-
|
|
30528
|
+
}
|
|
30529
|
+
break;
|
|
30495
30530
|
}
|
|
30531
|
+
}
|
|
30496
30532
|
#endif
|
|
30497
|
-
|
|
30498
|
-
|
|
30533
|
+
if ((sizeof(int) <= sizeof(long))) {
|
|
30534
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
|
|
30499
30535
|
#ifdef HAVE_LONG_LONG
|
|
30500
|
-
|
|
30501
|
-
|
|
30536
|
+
} else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) {
|
|
30537
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
|
|
30502
30538
|
#endif
|
|
30503
|
-
|
|
30539
|
+
}
|
|
30540
|
+
}
|
|
30541
|
+
{
|
|
30542
|
+
int val;
|
|
30543
|
+
int ret = -1;
|
|
30544
|
+
#if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
30545
|
+
Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
|
|
30546
|
+
x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
|
|
30547
|
+
if (unlikely(bytes_copied == -1)) {
|
|
30548
|
+
} else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
|
|
30549
|
+
goto raise_overflow;
|
|
30550
|
+
} else {
|
|
30551
|
+
ret = 0;
|
|
30552
|
+
}
|
|
30553
|
+
#elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
30554
|
+
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
30555
|
+
unsigned char *bytes = (unsigned char *)&val;
|
|
30556
|
+
ret = _PyLong_AsByteArray((PyLongObject *)x,
|
|
30557
|
+
bytes, sizeof(val),
|
|
30558
|
+
is_little, !is_unsigned);
|
|
30559
|
+
#else
|
|
30560
|
+
PyObject *v;
|
|
30561
|
+
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
30562
|
+
int bits, remaining_bits, is_negative = 0;
|
|
30563
|
+
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
30564
|
+
if (likely(PyLong_CheckExact(x))) {
|
|
30565
|
+
v = __Pyx_NewRef(x);
|
|
30566
|
+
} else {
|
|
30567
|
+
v = PyNumber_Long(x);
|
|
30568
|
+
if (unlikely(!v)) return (int) -1;
|
|
30569
|
+
assert(PyLong_CheckExact(v));
|
|
30504
30570
|
}
|
|
30505
30571
|
{
|
|
30506
|
-
int
|
|
30507
|
-
|
|
30508
|
-
#if PY_MAJOR_VERSION < 3
|
|
30509
|
-
if (likely(v) && !PyLong_Check(v)) {
|
|
30510
|
-
PyObject *tmp = v;
|
|
30511
|
-
v = PyNumber_Long(tmp);
|
|
30512
|
-
Py_DECREF(tmp);
|
|
30513
|
-
}
|
|
30514
|
-
#endif
|
|
30515
|
-
if (likely(v)) {
|
|
30516
|
-
int ret = -1;
|
|
30517
|
-
#if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
30518
|
-
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
30519
|
-
unsigned char *bytes = (unsigned char *)&val;
|
|
30520
|
-
ret = _PyLong_AsByteArray((PyLongObject *)v,
|
|
30521
|
-
bytes, sizeof(val),
|
|
30522
|
-
is_little, !is_unsigned);
|
|
30523
|
-
#else
|
|
30524
|
-
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
30525
|
-
int bits, remaining_bits, is_negative = 0;
|
|
30526
|
-
long idigit;
|
|
30527
|
-
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
30528
|
-
if (unlikely(!PyLong_CheckExact(v))) {
|
|
30529
|
-
PyObject *tmp = v;
|
|
30530
|
-
v = PyNumber_Long(v);
|
|
30531
|
-
assert(PyLong_CheckExact(v));
|
|
30532
|
-
Py_DECREF(tmp);
|
|
30533
|
-
if (unlikely(!v)) return (int) -1;
|
|
30534
|
-
}
|
|
30535
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
30536
|
-
if (Py_SIZE(x) == 0)
|
|
30537
|
-
return (int) 0;
|
|
30538
|
-
is_negative = Py_SIZE(x) < 0;
|
|
30539
|
-
#else
|
|
30540
|
-
{
|
|
30541
|
-
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
30542
|
-
if (unlikely(result < 0))
|
|
30543
|
-
return (int) -1;
|
|
30544
|
-
is_negative = result == 1;
|
|
30545
|
-
}
|
|
30546
|
-
#endif
|
|
30547
|
-
if (is_unsigned && unlikely(is_negative)) {
|
|
30548
|
-
goto raise_neg_overflow;
|
|
30549
|
-
} else if (is_negative) {
|
|
30550
|
-
stepval = PyNumber_Invert(v);
|
|
30551
|
-
if (unlikely(!stepval))
|
|
30552
|
-
return (int) -1;
|
|
30553
|
-
} else {
|
|
30554
|
-
stepval = __Pyx_NewRef(v);
|
|
30555
|
-
}
|
|
30556
|
-
val = (int) 0;
|
|
30557
|
-
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
30558
|
-
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
30559
|
-
for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
|
|
30560
|
-
PyObject *tmp, *digit;
|
|
30561
|
-
digit = PyNumber_And(stepval, mask);
|
|
30562
|
-
if (unlikely(!digit)) goto done;
|
|
30563
|
-
idigit = PyLong_AsLong(digit);
|
|
30564
|
-
Py_DECREF(digit);
|
|
30565
|
-
if (unlikely(idigit < 0)) goto done;
|
|
30566
|
-
tmp = PyNumber_Rshift(stepval, shift);
|
|
30567
|
-
if (unlikely(!tmp)) goto done;
|
|
30568
|
-
Py_DECREF(stepval); stepval = tmp;
|
|
30569
|
-
val |= ((int) idigit) << bits;
|
|
30570
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
30571
|
-
if (Py_SIZE(stepval) == 0)
|
|
30572
|
-
goto unpacking_done;
|
|
30573
|
-
#endif
|
|
30574
|
-
}
|
|
30575
|
-
idigit = PyLong_AsLong(stepval);
|
|
30576
|
-
if (unlikely(idigit < 0)) goto done;
|
|
30577
|
-
remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
30578
|
-
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
30579
|
-
goto raise_overflow;
|
|
30580
|
-
val |= ((int) idigit) << bits;
|
|
30581
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
30582
|
-
unpacking_done:
|
|
30583
|
-
#endif
|
|
30584
|
-
if (!is_unsigned) {
|
|
30585
|
-
if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
|
|
30586
|
-
goto raise_overflow;
|
|
30587
|
-
if (is_negative)
|
|
30588
|
-
val = ~val;
|
|
30589
|
-
}
|
|
30590
|
-
ret = 0;
|
|
30591
|
-
done:
|
|
30592
|
-
Py_XDECREF(shift);
|
|
30593
|
-
Py_XDECREF(mask);
|
|
30594
|
-
Py_XDECREF(stepval);
|
|
30595
|
-
#endif
|
|
30572
|
+
int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
|
|
30573
|
+
if (unlikely(result < 0)) {
|
|
30596
30574
|
Py_DECREF(v);
|
|
30597
|
-
|
|
30598
|
-
return val;
|
|
30575
|
+
return (int) -1;
|
|
30599
30576
|
}
|
|
30600
|
-
|
|
30577
|
+
is_negative = result == 1;
|
|
30578
|
+
}
|
|
30579
|
+
if (is_unsigned && unlikely(is_negative)) {
|
|
30580
|
+
Py_DECREF(v);
|
|
30581
|
+
goto raise_neg_overflow;
|
|
30582
|
+
} else if (is_negative) {
|
|
30583
|
+
stepval = PyNumber_Invert(v);
|
|
30584
|
+
Py_DECREF(v);
|
|
30585
|
+
if (unlikely(!stepval))
|
|
30586
|
+
return (int) -1;
|
|
30587
|
+
} else {
|
|
30588
|
+
stepval = v;
|
|
30589
|
+
}
|
|
30590
|
+
v = NULL;
|
|
30591
|
+
val = (int) 0;
|
|
30592
|
+
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
30593
|
+
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
30594
|
+
for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
|
|
30595
|
+
PyObject *tmp, *digit;
|
|
30596
|
+
long idigit;
|
|
30597
|
+
digit = PyNumber_And(stepval, mask);
|
|
30598
|
+
if (unlikely(!digit)) goto done;
|
|
30599
|
+
idigit = PyLong_AsLong(digit);
|
|
30600
|
+
Py_DECREF(digit);
|
|
30601
|
+
if (unlikely(idigit < 0)) goto done;
|
|
30602
|
+
val |= ((int) idigit) << bits;
|
|
30603
|
+
tmp = PyNumber_Rshift(stepval, shift);
|
|
30604
|
+
if (unlikely(!tmp)) goto done;
|
|
30605
|
+
Py_DECREF(stepval); stepval = tmp;
|
|
30606
|
+
}
|
|
30607
|
+
Py_DECREF(shift); shift = NULL;
|
|
30608
|
+
Py_DECREF(mask); mask = NULL;
|
|
30609
|
+
{
|
|
30610
|
+
long idigit = PyLong_AsLong(stepval);
|
|
30611
|
+
if (unlikely(idigit < 0)) goto done;
|
|
30612
|
+
remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
30613
|
+
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
30614
|
+
goto raise_overflow;
|
|
30615
|
+
val |= ((int) idigit) << bits;
|
|
30601
30616
|
}
|
|
30602
|
-
|
|
30603
|
-
|
|
30604
|
-
|
|
30605
|
-
|
|
30606
|
-
|
|
30607
|
-
|
|
30617
|
+
if (!is_unsigned) {
|
|
30618
|
+
if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
|
|
30619
|
+
goto raise_overflow;
|
|
30620
|
+
if (is_negative)
|
|
30621
|
+
val = ~val;
|
|
30622
|
+
}
|
|
30623
|
+
ret = 0;
|
|
30624
|
+
done:
|
|
30625
|
+
Py_XDECREF(shift);
|
|
30626
|
+
Py_XDECREF(mask);
|
|
30627
|
+
Py_XDECREF(stepval);
|
|
30628
|
+
#endif
|
|
30629
|
+
if (unlikely(ret))
|
|
30630
|
+
return (int) -1;
|
|
30608
30631
|
return val;
|
|
30609
30632
|
}
|
|
30610
30633
|
raise_overflow:
|
|
@@ -30639,245 +30662,239 @@ raise_neg_overflow:
|
|
|
30639
30662
|
}
|
|
30640
30663
|
return (long) val;
|
|
30641
30664
|
}
|
|
30642
|
-
}
|
|
30665
|
+
}
|
|
30643
30666
|
#endif
|
|
30644
|
-
if (
|
|
30645
|
-
|
|
30667
|
+
if (unlikely(!PyLong_Check(x))) {
|
|
30668
|
+
long val;
|
|
30669
|
+
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
|
|
30670
|
+
if (!tmp) return (long) -1;
|
|
30671
|
+
val = __Pyx_PyInt_As_long(tmp);
|
|
30672
|
+
Py_DECREF(tmp);
|
|
30673
|
+
return val;
|
|
30674
|
+
}
|
|
30675
|
+
if (is_unsigned) {
|
|
30646
30676
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
30647
|
-
|
|
30648
|
-
|
|
30649
|
-
|
|
30650
|
-
|
|
30651
|
-
|
|
30652
|
-
|
|
30653
|
-
|
|
30654
|
-
|
|
30655
|
-
|
|
30656
|
-
|
|
30657
|
-
|
|
30658
|
-
|
|
30659
|
-
|
|
30660
|
-
|
|
30661
|
-
}
|
|
30677
|
+
if (unlikely(__Pyx_PyLong_IsNeg(x))) {
|
|
30678
|
+
goto raise_neg_overflow;
|
|
30679
|
+
} else if (__Pyx_PyLong_IsCompact(x)) {
|
|
30680
|
+
__PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
|
|
30681
|
+
} else {
|
|
30682
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
30683
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
30684
|
+
switch (__Pyx_PyLong_DigitCount(x)) {
|
|
30685
|
+
case 2:
|
|
30686
|
+
if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
|
|
30687
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
30688
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30689
|
+
} else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) {
|
|
30690
|
+
return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
|
|
30662
30691
|
}
|
|
30663
|
-
|
|
30664
|
-
|
|
30665
|
-
|
|
30666
|
-
|
|
30667
|
-
|
|
30668
|
-
|
|
30669
|
-
|
|
30670
|
-
|
|
30692
|
+
}
|
|
30693
|
+
break;
|
|
30694
|
+
case 3:
|
|
30695
|
+
if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
|
|
30696
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
30697
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30698
|
+
} else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) {
|
|
30699
|
+
return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
|
|
30671
30700
|
}
|
|
30672
|
-
|
|
30673
|
-
|
|
30674
|
-
|
|
30675
|
-
|
|
30676
|
-
|
|
30677
|
-
|
|
30678
|
-
|
|
30679
|
-
|
|
30701
|
+
}
|
|
30702
|
+
break;
|
|
30703
|
+
case 4:
|
|
30704
|
+
if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
|
|
30705
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
30706
|
+
__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])))
|
|
30707
|
+
} else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) {
|
|
30708
|
+
return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
|
|
30680
30709
|
}
|
|
30681
|
-
|
|
30682
|
-
|
|
30710
|
+
}
|
|
30711
|
+
break;
|
|
30683
30712
|
}
|
|
30713
|
+
}
|
|
30684
30714
|
#endif
|
|
30685
30715
|
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
|
|
30686
|
-
|
|
30687
|
-
|
|
30688
|
-
|
|
30716
|
+
if (unlikely(Py_SIZE(x) < 0)) {
|
|
30717
|
+
goto raise_neg_overflow;
|
|
30718
|
+
}
|
|
30689
30719
|
#else
|
|
30690
|
-
|
|
30691
|
-
|
|
30692
|
-
|
|
30693
|
-
|
|
30694
|
-
|
|
30695
|
-
|
|
30696
|
-
|
|
30720
|
+
{
|
|
30721
|
+
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
30722
|
+
if (unlikely(result < 0))
|
|
30723
|
+
return (long) -1;
|
|
30724
|
+
if (unlikely(result == 1))
|
|
30725
|
+
goto raise_neg_overflow;
|
|
30726
|
+
}
|
|
30697
30727
|
#endif
|
|
30698
|
-
|
|
30699
|
-
|
|
30728
|
+
if ((sizeof(long) <= sizeof(unsigned long))) {
|
|
30729
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
|
|
30700
30730
|
#ifdef HAVE_LONG_LONG
|
|
30701
|
-
|
|
30702
|
-
|
|
30731
|
+
} else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) {
|
|
30732
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
|
|
30703
30733
|
#endif
|
|
30704
|
-
|
|
30705
|
-
|
|
30734
|
+
}
|
|
30735
|
+
} else {
|
|
30706
30736
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
30707
|
-
|
|
30708
|
-
|
|
30709
|
-
|
|
30710
|
-
|
|
30711
|
-
|
|
30712
|
-
|
|
30713
|
-
|
|
30714
|
-
|
|
30715
|
-
|
|
30716
|
-
|
|
30717
|
-
|
|
30718
|
-
|
|
30719
|
-
}
|
|
30737
|
+
if (__Pyx_PyLong_IsCompact(x)) {
|
|
30738
|
+
__PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
|
|
30739
|
+
} else {
|
|
30740
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
30741
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
30742
|
+
switch (__Pyx_PyLong_SignedDigitCount(x)) {
|
|
30743
|
+
case -2:
|
|
30744
|
+
if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) {
|
|
30745
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
30746
|
+
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30747
|
+
} else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
|
|
30748
|
+
return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
30720
30749
|
}
|
|
30721
|
-
|
|
30722
|
-
|
|
30723
|
-
|
|
30724
|
-
|
|
30725
|
-
|
|
30726
|
-
|
|
30727
|
-
|
|
30728
|
-
|
|
30750
|
+
}
|
|
30751
|
+
break;
|
|
30752
|
+
case 2:
|
|
30753
|
+
if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
|
|
30754
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
30755
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30756
|
+
} else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
|
|
30757
|
+
return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
30729
30758
|
}
|
|
30730
|
-
|
|
30731
|
-
|
|
30732
|
-
|
|
30733
|
-
|
|
30734
|
-
|
|
30735
|
-
|
|
30736
|
-
|
|
30737
|
-
|
|
30759
|
+
}
|
|
30760
|
+
break;
|
|
30761
|
+
case -3:
|
|
30762
|
+
if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
|
|
30763
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
30764
|
+
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30765
|
+
} else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
|
|
30766
|
+
return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
30738
30767
|
}
|
|
30739
|
-
|
|
30740
|
-
|
|
30741
|
-
|
|
30742
|
-
|
|
30743
|
-
|
|
30744
|
-
|
|
30745
|
-
|
|
30746
|
-
|
|
30768
|
+
}
|
|
30769
|
+
break;
|
|
30770
|
+
case 3:
|
|
30771
|
+
if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
|
|
30772
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
30773
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30774
|
+
} else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
|
|
30775
|
+
return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
30747
30776
|
}
|
|
30748
|
-
|
|
30749
|
-
|
|
30750
|
-
|
|
30751
|
-
|
|
30752
|
-
|
|
30753
|
-
|
|
30754
|
-
|
|
30755
|
-
|
|
30777
|
+
}
|
|
30778
|
+
break;
|
|
30779
|
+
case -4:
|
|
30780
|
+
if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
|
|
30781
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
30782
|
+
__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])))
|
|
30783
|
+
} else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
|
|
30784
|
+
return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
30756
30785
|
}
|
|
30757
|
-
|
|
30758
|
-
|
|
30759
|
-
|
|
30760
|
-
|
|
30761
|
-
|
|
30762
|
-
|
|
30763
|
-
|
|
30764
|
-
|
|
30786
|
+
}
|
|
30787
|
+
break;
|
|
30788
|
+
case 4:
|
|
30789
|
+
if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
|
|
30790
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
30791
|
+
__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])))
|
|
30792
|
+
} else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
|
|
30793
|
+
return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
30765
30794
|
}
|
|
30766
|
-
|
|
30767
|
-
|
|
30795
|
+
}
|
|
30796
|
+
break;
|
|
30768
30797
|
}
|
|
30798
|
+
}
|
|
30769
30799
|
#endif
|
|
30770
|
-
|
|
30771
|
-
|
|
30800
|
+
if ((sizeof(long) <= sizeof(long))) {
|
|
30801
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
|
|
30772
30802
|
#ifdef HAVE_LONG_LONG
|
|
30773
|
-
|
|
30774
|
-
|
|
30803
|
+
} else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) {
|
|
30804
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
|
|
30775
30805
|
#endif
|
|
30776
|
-
|
|
30806
|
+
}
|
|
30807
|
+
}
|
|
30808
|
+
{
|
|
30809
|
+
long val;
|
|
30810
|
+
int ret = -1;
|
|
30811
|
+
#if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
30812
|
+
Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
|
|
30813
|
+
x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
|
|
30814
|
+
if (unlikely(bytes_copied == -1)) {
|
|
30815
|
+
} else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
|
|
30816
|
+
goto raise_overflow;
|
|
30817
|
+
} else {
|
|
30818
|
+
ret = 0;
|
|
30819
|
+
}
|
|
30820
|
+
#elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
30821
|
+
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
30822
|
+
unsigned char *bytes = (unsigned char *)&val;
|
|
30823
|
+
ret = _PyLong_AsByteArray((PyLongObject *)x,
|
|
30824
|
+
bytes, sizeof(val),
|
|
30825
|
+
is_little, !is_unsigned);
|
|
30826
|
+
#else
|
|
30827
|
+
PyObject *v;
|
|
30828
|
+
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
30829
|
+
int bits, remaining_bits, is_negative = 0;
|
|
30830
|
+
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
30831
|
+
if (likely(PyLong_CheckExact(x))) {
|
|
30832
|
+
v = __Pyx_NewRef(x);
|
|
30833
|
+
} else {
|
|
30834
|
+
v = PyNumber_Long(x);
|
|
30835
|
+
if (unlikely(!v)) return (long) -1;
|
|
30836
|
+
assert(PyLong_CheckExact(v));
|
|
30777
30837
|
}
|
|
30778
30838
|
{
|
|
30779
|
-
|
|
30780
|
-
|
|
30781
|
-
#if PY_MAJOR_VERSION < 3
|
|
30782
|
-
if (likely(v) && !PyLong_Check(v)) {
|
|
30783
|
-
PyObject *tmp = v;
|
|
30784
|
-
v = PyNumber_Long(tmp);
|
|
30785
|
-
Py_DECREF(tmp);
|
|
30786
|
-
}
|
|
30787
|
-
#endif
|
|
30788
|
-
if (likely(v)) {
|
|
30789
|
-
int ret = -1;
|
|
30790
|
-
#if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
30791
|
-
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
30792
|
-
unsigned char *bytes = (unsigned char *)&val;
|
|
30793
|
-
ret = _PyLong_AsByteArray((PyLongObject *)v,
|
|
30794
|
-
bytes, sizeof(val),
|
|
30795
|
-
is_little, !is_unsigned);
|
|
30796
|
-
#else
|
|
30797
|
-
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
30798
|
-
int bits, remaining_bits, is_negative = 0;
|
|
30799
|
-
long idigit;
|
|
30800
|
-
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
30801
|
-
if (unlikely(!PyLong_CheckExact(v))) {
|
|
30802
|
-
PyObject *tmp = v;
|
|
30803
|
-
v = PyNumber_Long(v);
|
|
30804
|
-
assert(PyLong_CheckExact(v));
|
|
30805
|
-
Py_DECREF(tmp);
|
|
30806
|
-
if (unlikely(!v)) return (long) -1;
|
|
30807
|
-
}
|
|
30808
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
30809
|
-
if (Py_SIZE(x) == 0)
|
|
30810
|
-
return (long) 0;
|
|
30811
|
-
is_negative = Py_SIZE(x) < 0;
|
|
30812
|
-
#else
|
|
30813
|
-
{
|
|
30814
|
-
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
30815
|
-
if (unlikely(result < 0))
|
|
30816
|
-
return (long) -1;
|
|
30817
|
-
is_negative = result == 1;
|
|
30818
|
-
}
|
|
30819
|
-
#endif
|
|
30820
|
-
if (is_unsigned && unlikely(is_negative)) {
|
|
30821
|
-
goto raise_neg_overflow;
|
|
30822
|
-
} else if (is_negative) {
|
|
30823
|
-
stepval = PyNumber_Invert(v);
|
|
30824
|
-
if (unlikely(!stepval))
|
|
30825
|
-
return (long) -1;
|
|
30826
|
-
} else {
|
|
30827
|
-
stepval = __Pyx_NewRef(v);
|
|
30828
|
-
}
|
|
30829
|
-
val = (long) 0;
|
|
30830
|
-
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
30831
|
-
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
30832
|
-
for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
|
|
30833
|
-
PyObject *tmp, *digit;
|
|
30834
|
-
digit = PyNumber_And(stepval, mask);
|
|
30835
|
-
if (unlikely(!digit)) goto done;
|
|
30836
|
-
idigit = PyLong_AsLong(digit);
|
|
30837
|
-
Py_DECREF(digit);
|
|
30838
|
-
if (unlikely(idigit < 0)) goto done;
|
|
30839
|
-
tmp = PyNumber_Rshift(stepval, shift);
|
|
30840
|
-
if (unlikely(!tmp)) goto done;
|
|
30841
|
-
Py_DECREF(stepval); stepval = tmp;
|
|
30842
|
-
val |= ((long) idigit) << bits;
|
|
30843
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
30844
|
-
if (Py_SIZE(stepval) == 0)
|
|
30845
|
-
goto unpacking_done;
|
|
30846
|
-
#endif
|
|
30847
|
-
}
|
|
30848
|
-
idigit = PyLong_AsLong(stepval);
|
|
30849
|
-
if (unlikely(idigit < 0)) goto done;
|
|
30850
|
-
remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
30851
|
-
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
30852
|
-
goto raise_overflow;
|
|
30853
|
-
val |= ((long) idigit) << bits;
|
|
30854
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
30855
|
-
unpacking_done:
|
|
30856
|
-
#endif
|
|
30857
|
-
if (!is_unsigned) {
|
|
30858
|
-
if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
|
|
30859
|
-
goto raise_overflow;
|
|
30860
|
-
if (is_negative)
|
|
30861
|
-
val = ~val;
|
|
30862
|
-
}
|
|
30863
|
-
ret = 0;
|
|
30864
|
-
done:
|
|
30865
|
-
Py_XDECREF(shift);
|
|
30866
|
-
Py_XDECREF(mask);
|
|
30867
|
-
Py_XDECREF(stepval);
|
|
30868
|
-
#endif
|
|
30839
|
+
int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
|
|
30840
|
+
if (unlikely(result < 0)) {
|
|
30869
30841
|
Py_DECREF(v);
|
|
30870
|
-
|
|
30871
|
-
return val;
|
|
30842
|
+
return (long) -1;
|
|
30872
30843
|
}
|
|
30873
|
-
|
|
30844
|
+
is_negative = result == 1;
|
|
30845
|
+
}
|
|
30846
|
+
if (is_unsigned && unlikely(is_negative)) {
|
|
30847
|
+
Py_DECREF(v);
|
|
30848
|
+
goto raise_neg_overflow;
|
|
30849
|
+
} else if (is_negative) {
|
|
30850
|
+
stepval = PyNumber_Invert(v);
|
|
30851
|
+
Py_DECREF(v);
|
|
30852
|
+
if (unlikely(!stepval))
|
|
30853
|
+
return (long) -1;
|
|
30854
|
+
} else {
|
|
30855
|
+
stepval = v;
|
|
30856
|
+
}
|
|
30857
|
+
v = NULL;
|
|
30858
|
+
val = (long) 0;
|
|
30859
|
+
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
30860
|
+
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
30861
|
+
for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
|
|
30862
|
+
PyObject *tmp, *digit;
|
|
30863
|
+
long idigit;
|
|
30864
|
+
digit = PyNumber_And(stepval, mask);
|
|
30865
|
+
if (unlikely(!digit)) goto done;
|
|
30866
|
+
idigit = PyLong_AsLong(digit);
|
|
30867
|
+
Py_DECREF(digit);
|
|
30868
|
+
if (unlikely(idigit < 0)) goto done;
|
|
30869
|
+
val |= ((long) idigit) << bits;
|
|
30870
|
+
tmp = PyNumber_Rshift(stepval, shift);
|
|
30871
|
+
if (unlikely(!tmp)) goto done;
|
|
30872
|
+
Py_DECREF(stepval); stepval = tmp;
|
|
30873
|
+
}
|
|
30874
|
+
Py_DECREF(shift); shift = NULL;
|
|
30875
|
+
Py_DECREF(mask); mask = NULL;
|
|
30876
|
+
{
|
|
30877
|
+
long idigit = PyLong_AsLong(stepval);
|
|
30878
|
+
if (unlikely(idigit < 0)) goto done;
|
|
30879
|
+
remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
30880
|
+
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
30881
|
+
goto raise_overflow;
|
|
30882
|
+
val |= ((long) idigit) << bits;
|
|
30874
30883
|
}
|
|
30875
|
-
|
|
30876
|
-
|
|
30877
|
-
|
|
30878
|
-
|
|
30879
|
-
|
|
30880
|
-
|
|
30884
|
+
if (!is_unsigned) {
|
|
30885
|
+
if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
|
|
30886
|
+
goto raise_overflow;
|
|
30887
|
+
if (is_negative)
|
|
30888
|
+
val = ~val;
|
|
30889
|
+
}
|
|
30890
|
+
ret = 0;
|
|
30891
|
+
done:
|
|
30892
|
+
Py_XDECREF(shift);
|
|
30893
|
+
Py_XDECREF(mask);
|
|
30894
|
+
Py_XDECREF(stepval);
|
|
30895
|
+
#endif
|
|
30896
|
+
if (unlikely(ret))
|
|
30897
|
+
return (long) -1;
|
|
30881
30898
|
return val;
|
|
30882
30899
|
}
|
|
30883
30900
|
raise_overflow:
|
|
@@ -30938,245 +30955,239 @@ static CYTHON_INLINE PyObject* __Pyx_ImportNumPyArrayTypeIfAvailable(void) {
|
|
|
30938
30955
|
}
|
|
30939
30956
|
return (char) val;
|
|
30940
30957
|
}
|
|
30941
|
-
}
|
|
30958
|
+
}
|
|
30942
30959
|
#endif
|
|
30943
|
-
if (
|
|
30944
|
-
|
|
30960
|
+
if (unlikely(!PyLong_Check(x))) {
|
|
30961
|
+
char val;
|
|
30962
|
+
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
|
|
30963
|
+
if (!tmp) return (char) -1;
|
|
30964
|
+
val = __Pyx_PyInt_As_char(tmp);
|
|
30965
|
+
Py_DECREF(tmp);
|
|
30966
|
+
return val;
|
|
30967
|
+
}
|
|
30968
|
+
if (is_unsigned) {
|
|
30945
30969
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
30946
|
-
|
|
30947
|
-
|
|
30948
|
-
|
|
30949
|
-
|
|
30950
|
-
|
|
30951
|
-
|
|
30952
|
-
|
|
30953
|
-
|
|
30954
|
-
|
|
30955
|
-
|
|
30956
|
-
|
|
30957
|
-
|
|
30958
|
-
|
|
30959
|
-
|
|
30960
|
-
}
|
|
30970
|
+
if (unlikely(__Pyx_PyLong_IsNeg(x))) {
|
|
30971
|
+
goto raise_neg_overflow;
|
|
30972
|
+
} else if (__Pyx_PyLong_IsCompact(x)) {
|
|
30973
|
+
__PYX_VERIFY_RETURN_INT(char, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
|
|
30974
|
+
} else {
|
|
30975
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
30976
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
30977
|
+
switch (__Pyx_PyLong_DigitCount(x)) {
|
|
30978
|
+
case 2:
|
|
30979
|
+
if ((8 * sizeof(char) > 1 * PyLong_SHIFT)) {
|
|
30980
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
30981
|
+
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30982
|
+
} else if ((8 * sizeof(char) >= 2 * PyLong_SHIFT)) {
|
|
30983
|
+
return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
|
|
30961
30984
|
}
|
|
30962
|
-
|
|
30963
|
-
|
|
30964
|
-
|
|
30965
|
-
|
|
30966
|
-
|
|
30967
|
-
|
|
30968
|
-
|
|
30969
|
-
|
|
30985
|
+
}
|
|
30986
|
+
break;
|
|
30987
|
+
case 3:
|
|
30988
|
+
if ((8 * sizeof(char) > 2 * PyLong_SHIFT)) {
|
|
30989
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
30990
|
+
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
30991
|
+
} else if ((8 * sizeof(char) >= 3 * PyLong_SHIFT)) {
|
|
30992
|
+
return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
|
|
30970
30993
|
}
|
|
30971
|
-
|
|
30972
|
-
|
|
30973
|
-
|
|
30974
|
-
|
|
30975
|
-
|
|
30976
|
-
|
|
30977
|
-
|
|
30978
|
-
|
|
30994
|
+
}
|
|
30995
|
+
break;
|
|
30996
|
+
case 4:
|
|
30997
|
+
if ((8 * sizeof(char) > 3 * PyLong_SHIFT)) {
|
|
30998
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
30999
|
+
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
31000
|
+
} else if ((8 * sizeof(char) >= 4 * PyLong_SHIFT)) {
|
|
31001
|
+
return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
|
|
30979
31002
|
}
|
|
30980
|
-
|
|
30981
|
-
|
|
31003
|
+
}
|
|
31004
|
+
break;
|
|
30982
31005
|
}
|
|
31006
|
+
}
|
|
30983
31007
|
#endif
|
|
30984
31008
|
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
|
|
30985
|
-
|
|
30986
|
-
|
|
30987
|
-
|
|
31009
|
+
if (unlikely(Py_SIZE(x) < 0)) {
|
|
31010
|
+
goto raise_neg_overflow;
|
|
31011
|
+
}
|
|
30988
31012
|
#else
|
|
30989
|
-
|
|
30990
|
-
|
|
30991
|
-
|
|
30992
|
-
|
|
30993
|
-
|
|
30994
|
-
|
|
30995
|
-
|
|
31013
|
+
{
|
|
31014
|
+
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
31015
|
+
if (unlikely(result < 0))
|
|
31016
|
+
return (char) -1;
|
|
31017
|
+
if (unlikely(result == 1))
|
|
31018
|
+
goto raise_neg_overflow;
|
|
31019
|
+
}
|
|
30996
31020
|
#endif
|
|
30997
|
-
|
|
30998
|
-
|
|
31021
|
+
if ((sizeof(char) <= sizeof(unsigned long))) {
|
|
31022
|
+
__PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
|
|
30999
31023
|
#ifdef HAVE_LONG_LONG
|
|
31000
|
-
|
|
31001
|
-
|
|
31024
|
+
} else if ((sizeof(char) <= sizeof(unsigned PY_LONG_LONG))) {
|
|
31025
|
+
__PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
|
|
31002
31026
|
#endif
|
|
31003
|
-
|
|
31004
|
-
|
|
31027
|
+
}
|
|
31028
|
+
} else {
|
|
31005
31029
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
31006
|
-
|
|
31007
|
-
|
|
31008
|
-
|
|
31009
|
-
|
|
31010
|
-
|
|
31011
|
-
|
|
31012
|
-
|
|
31013
|
-
|
|
31014
|
-
|
|
31015
|
-
|
|
31016
|
-
|
|
31017
|
-
|
|
31018
|
-
}
|
|
31030
|
+
if (__Pyx_PyLong_IsCompact(x)) {
|
|
31031
|
+
__PYX_VERIFY_RETURN_INT(char, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
|
|
31032
|
+
} else {
|
|
31033
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
31034
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
31035
|
+
switch (__Pyx_PyLong_SignedDigitCount(x)) {
|
|
31036
|
+
case -2:
|
|
31037
|
+
if ((8 * sizeof(char) - 1 > 1 * PyLong_SHIFT)) {
|
|
31038
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
31039
|
+
__PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
31040
|
+
} else if ((8 * sizeof(char) - 1 > 2 * PyLong_SHIFT)) {
|
|
31041
|
+
return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
|
|
31019
31042
|
}
|
|
31020
|
-
|
|
31021
|
-
|
|
31022
|
-
|
|
31023
|
-
|
|
31024
|
-
|
|
31025
|
-
|
|
31026
|
-
|
|
31027
|
-
|
|
31043
|
+
}
|
|
31044
|
+
break;
|
|
31045
|
+
case 2:
|
|
31046
|
+
if ((8 * sizeof(char) > 1 * PyLong_SHIFT)) {
|
|
31047
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
31048
|
+
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
31049
|
+
} else if ((8 * sizeof(char) - 1 > 2 * PyLong_SHIFT)) {
|
|
31050
|
+
return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
|
|
31028
31051
|
}
|
|
31029
|
-
|
|
31030
|
-
|
|
31031
|
-
|
|
31032
|
-
|
|
31033
|
-
|
|
31034
|
-
|
|
31035
|
-
|
|
31036
|
-
|
|
31052
|
+
}
|
|
31053
|
+
break;
|
|
31054
|
+
case -3:
|
|
31055
|
+
if ((8 * sizeof(char) - 1 > 2 * PyLong_SHIFT)) {
|
|
31056
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
31057
|
+
__PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
31058
|
+
} else if ((8 * sizeof(char) - 1 > 3 * PyLong_SHIFT)) {
|
|
31059
|
+
return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
|
|
31037
31060
|
}
|
|
31038
|
-
|
|
31039
|
-
|
|
31040
|
-
|
|
31041
|
-
|
|
31042
|
-
|
|
31043
|
-
|
|
31044
|
-
|
|
31045
|
-
|
|
31061
|
+
}
|
|
31062
|
+
break;
|
|
31063
|
+
case 3:
|
|
31064
|
+
if ((8 * sizeof(char) > 2 * PyLong_SHIFT)) {
|
|
31065
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
31066
|
+
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
31067
|
+
} else if ((8 * sizeof(char) - 1 > 3 * PyLong_SHIFT)) {
|
|
31068
|
+
return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
|
|
31046
31069
|
}
|
|
31047
|
-
|
|
31048
|
-
|
|
31049
|
-
|
|
31050
|
-
|
|
31051
|
-
|
|
31052
|
-
|
|
31053
|
-
|
|
31054
|
-
|
|
31070
|
+
}
|
|
31071
|
+
break;
|
|
31072
|
+
case -4:
|
|
31073
|
+
if ((8 * sizeof(char) - 1 > 3 * PyLong_SHIFT)) {
|
|
31074
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
31075
|
+
__PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
31076
|
+
} else if ((8 * sizeof(char) - 1 > 4 * PyLong_SHIFT)) {
|
|
31077
|
+
return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
|
|
31055
31078
|
}
|
|
31056
|
-
|
|
31057
|
-
|
|
31058
|
-
|
|
31059
|
-
|
|
31060
|
-
|
|
31061
|
-
|
|
31062
|
-
|
|
31063
|
-
|
|
31079
|
+
}
|
|
31080
|
+
break;
|
|
31081
|
+
case 4:
|
|
31082
|
+
if ((8 * sizeof(char) > 3 * PyLong_SHIFT)) {
|
|
31083
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
31084
|
+
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
31085
|
+
} else if ((8 * sizeof(char) - 1 > 4 * PyLong_SHIFT)) {
|
|
31086
|
+
return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
|
|
31064
31087
|
}
|
|
31065
|
-
|
|
31066
|
-
|
|
31088
|
+
}
|
|
31089
|
+
break;
|
|
31067
31090
|
}
|
|
31091
|
+
}
|
|
31068
31092
|
#endif
|
|
31069
|
-
|
|
31070
|
-
|
|
31093
|
+
if ((sizeof(char) <= sizeof(long))) {
|
|
31094
|
+
__PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
|
|
31071
31095
|
#ifdef HAVE_LONG_LONG
|
|
31072
|
-
|
|
31073
|
-
|
|
31096
|
+
} else if ((sizeof(char) <= sizeof(PY_LONG_LONG))) {
|
|
31097
|
+
__PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
|
|
31074
31098
|
#endif
|
|
31075
|
-
|
|
31099
|
+
}
|
|
31100
|
+
}
|
|
31101
|
+
{
|
|
31102
|
+
char val;
|
|
31103
|
+
int ret = -1;
|
|
31104
|
+
#if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
31105
|
+
Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
|
|
31106
|
+
x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
|
|
31107
|
+
if (unlikely(bytes_copied == -1)) {
|
|
31108
|
+
} else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
|
|
31109
|
+
goto raise_overflow;
|
|
31110
|
+
} else {
|
|
31111
|
+
ret = 0;
|
|
31112
|
+
}
|
|
31113
|
+
#elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
31114
|
+
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
31115
|
+
unsigned char *bytes = (unsigned char *)&val;
|
|
31116
|
+
ret = _PyLong_AsByteArray((PyLongObject *)x,
|
|
31117
|
+
bytes, sizeof(val),
|
|
31118
|
+
is_little, !is_unsigned);
|
|
31119
|
+
#else
|
|
31120
|
+
PyObject *v;
|
|
31121
|
+
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
31122
|
+
int bits, remaining_bits, is_negative = 0;
|
|
31123
|
+
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
31124
|
+
if (likely(PyLong_CheckExact(x))) {
|
|
31125
|
+
v = __Pyx_NewRef(x);
|
|
31126
|
+
} else {
|
|
31127
|
+
v = PyNumber_Long(x);
|
|
31128
|
+
if (unlikely(!v)) return (char) -1;
|
|
31129
|
+
assert(PyLong_CheckExact(v));
|
|
31076
31130
|
}
|
|
31077
31131
|
{
|
|
31078
|
-
|
|
31079
|
-
|
|
31080
|
-
#if PY_MAJOR_VERSION < 3
|
|
31081
|
-
if (likely(v) && !PyLong_Check(v)) {
|
|
31082
|
-
PyObject *tmp = v;
|
|
31083
|
-
v = PyNumber_Long(tmp);
|
|
31084
|
-
Py_DECREF(tmp);
|
|
31085
|
-
}
|
|
31086
|
-
#endif
|
|
31087
|
-
if (likely(v)) {
|
|
31088
|
-
int ret = -1;
|
|
31089
|
-
#if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
31090
|
-
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
31091
|
-
unsigned char *bytes = (unsigned char *)&val;
|
|
31092
|
-
ret = _PyLong_AsByteArray((PyLongObject *)v,
|
|
31093
|
-
bytes, sizeof(val),
|
|
31094
|
-
is_little, !is_unsigned);
|
|
31095
|
-
#else
|
|
31096
|
-
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
31097
|
-
int bits, remaining_bits, is_negative = 0;
|
|
31098
|
-
long idigit;
|
|
31099
|
-
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
31100
|
-
if (unlikely(!PyLong_CheckExact(v))) {
|
|
31101
|
-
PyObject *tmp = v;
|
|
31102
|
-
v = PyNumber_Long(v);
|
|
31103
|
-
assert(PyLong_CheckExact(v));
|
|
31104
|
-
Py_DECREF(tmp);
|
|
31105
|
-
if (unlikely(!v)) return (char) -1;
|
|
31106
|
-
}
|
|
31107
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
31108
|
-
if (Py_SIZE(x) == 0)
|
|
31109
|
-
return (char) 0;
|
|
31110
|
-
is_negative = Py_SIZE(x) < 0;
|
|
31111
|
-
#else
|
|
31112
|
-
{
|
|
31113
|
-
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
31114
|
-
if (unlikely(result < 0))
|
|
31115
|
-
return (char) -1;
|
|
31116
|
-
is_negative = result == 1;
|
|
31117
|
-
}
|
|
31118
|
-
#endif
|
|
31119
|
-
if (is_unsigned && unlikely(is_negative)) {
|
|
31120
|
-
goto raise_neg_overflow;
|
|
31121
|
-
} else if (is_negative) {
|
|
31122
|
-
stepval = PyNumber_Invert(v);
|
|
31123
|
-
if (unlikely(!stepval))
|
|
31124
|
-
return (char) -1;
|
|
31125
|
-
} else {
|
|
31126
|
-
stepval = __Pyx_NewRef(v);
|
|
31127
|
-
}
|
|
31128
|
-
val = (char) 0;
|
|
31129
|
-
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
31130
|
-
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
31131
|
-
for (bits = 0; bits < (int) sizeof(char) * 8 - chunk_size; bits += chunk_size) {
|
|
31132
|
-
PyObject *tmp, *digit;
|
|
31133
|
-
digit = PyNumber_And(stepval, mask);
|
|
31134
|
-
if (unlikely(!digit)) goto done;
|
|
31135
|
-
idigit = PyLong_AsLong(digit);
|
|
31136
|
-
Py_DECREF(digit);
|
|
31137
|
-
if (unlikely(idigit < 0)) goto done;
|
|
31138
|
-
tmp = PyNumber_Rshift(stepval, shift);
|
|
31139
|
-
if (unlikely(!tmp)) goto done;
|
|
31140
|
-
Py_DECREF(stepval); stepval = tmp;
|
|
31141
|
-
val |= ((char) idigit) << bits;
|
|
31142
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
31143
|
-
if (Py_SIZE(stepval) == 0)
|
|
31144
|
-
goto unpacking_done;
|
|
31145
|
-
#endif
|
|
31146
|
-
}
|
|
31147
|
-
idigit = PyLong_AsLong(stepval);
|
|
31148
|
-
if (unlikely(idigit < 0)) goto done;
|
|
31149
|
-
remaining_bits = ((int) sizeof(char) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
31150
|
-
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
31151
|
-
goto raise_overflow;
|
|
31152
|
-
val |= ((char) idigit) << bits;
|
|
31153
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
31154
|
-
unpacking_done:
|
|
31155
|
-
#endif
|
|
31156
|
-
if (!is_unsigned) {
|
|
31157
|
-
if (unlikely(val & (((char) 1) << (sizeof(char) * 8 - 1))))
|
|
31158
|
-
goto raise_overflow;
|
|
31159
|
-
if (is_negative)
|
|
31160
|
-
val = ~val;
|
|
31161
|
-
}
|
|
31162
|
-
ret = 0;
|
|
31163
|
-
done:
|
|
31164
|
-
Py_XDECREF(shift);
|
|
31165
|
-
Py_XDECREF(mask);
|
|
31166
|
-
Py_XDECREF(stepval);
|
|
31167
|
-
#endif
|
|
31132
|
+
int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
|
|
31133
|
+
if (unlikely(result < 0)) {
|
|
31168
31134
|
Py_DECREF(v);
|
|
31169
|
-
|
|
31170
|
-
return val;
|
|
31135
|
+
return (char) -1;
|
|
31171
31136
|
}
|
|
31172
|
-
|
|
31137
|
+
is_negative = result == 1;
|
|
31138
|
+
}
|
|
31139
|
+
if (is_unsigned && unlikely(is_negative)) {
|
|
31140
|
+
Py_DECREF(v);
|
|
31141
|
+
goto raise_neg_overflow;
|
|
31142
|
+
} else if (is_negative) {
|
|
31143
|
+
stepval = PyNumber_Invert(v);
|
|
31144
|
+
Py_DECREF(v);
|
|
31145
|
+
if (unlikely(!stepval))
|
|
31146
|
+
return (char) -1;
|
|
31147
|
+
} else {
|
|
31148
|
+
stepval = v;
|
|
31149
|
+
}
|
|
31150
|
+
v = NULL;
|
|
31151
|
+
val = (char) 0;
|
|
31152
|
+
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
31153
|
+
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
31154
|
+
for (bits = 0; bits < (int) sizeof(char) * 8 - chunk_size; bits += chunk_size) {
|
|
31155
|
+
PyObject *tmp, *digit;
|
|
31156
|
+
long idigit;
|
|
31157
|
+
digit = PyNumber_And(stepval, mask);
|
|
31158
|
+
if (unlikely(!digit)) goto done;
|
|
31159
|
+
idigit = PyLong_AsLong(digit);
|
|
31160
|
+
Py_DECREF(digit);
|
|
31161
|
+
if (unlikely(idigit < 0)) goto done;
|
|
31162
|
+
val |= ((char) idigit) << bits;
|
|
31163
|
+
tmp = PyNumber_Rshift(stepval, shift);
|
|
31164
|
+
if (unlikely(!tmp)) goto done;
|
|
31165
|
+
Py_DECREF(stepval); stepval = tmp;
|
|
31166
|
+
}
|
|
31167
|
+
Py_DECREF(shift); shift = NULL;
|
|
31168
|
+
Py_DECREF(mask); mask = NULL;
|
|
31169
|
+
{
|
|
31170
|
+
long idigit = PyLong_AsLong(stepval);
|
|
31171
|
+
if (unlikely(idigit < 0)) goto done;
|
|
31172
|
+
remaining_bits = ((int) sizeof(char) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
31173
|
+
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
31174
|
+
goto raise_overflow;
|
|
31175
|
+
val |= ((char) idigit) << bits;
|
|
31173
31176
|
}
|
|
31174
|
-
|
|
31175
|
-
|
|
31176
|
-
|
|
31177
|
-
|
|
31178
|
-
|
|
31179
|
-
|
|
31177
|
+
if (!is_unsigned) {
|
|
31178
|
+
if (unlikely(val & (((char) 1) << (sizeof(char) * 8 - 1))))
|
|
31179
|
+
goto raise_overflow;
|
|
31180
|
+
if (is_negative)
|
|
31181
|
+
val = ~val;
|
|
31182
|
+
}
|
|
31183
|
+
ret = 0;
|
|
31184
|
+
done:
|
|
31185
|
+
Py_XDECREF(shift);
|
|
31186
|
+
Py_XDECREF(mask);
|
|
31187
|
+
Py_XDECREF(stepval);
|
|
31188
|
+
#endif
|
|
31189
|
+
if (unlikely(ret))
|
|
31190
|
+
return (char) -1;
|
|
31180
31191
|
return val;
|
|
31181
31192
|
}
|
|
31182
31193
|
raise_overflow:
|