scikit-network 0.33.0__cp39-cp39-win_amd64.whl → 0.33.3__cp39-cp39-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.3.dist-info/METADATA +122 -0
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.3.dist-info}/RECORD +44 -44
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.3.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.cp39-win_amd64.pyd +0 -0
- sknetwork/classification/vote.cpp +686 -679
- sknetwork/clustering/leiden_core.cp39-win_amd64.pyd +0 -0
- sknetwork/clustering/leiden_core.cpp +715 -704
- sknetwork/clustering/louvain.py +3 -3
- sknetwork/clustering/louvain_core.cp39-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.cp39-win_amd64.pyd +0 -0
- sknetwork/hierarchy/paris.cpp +1777 -1155
- sknetwork/linalg/diteration.cp39-win_amd64.pyd +0 -0
- sknetwork/linalg/diteration.cpp +686 -679
- sknetwork/linalg/push.cp39-win_amd64.pyd +0 -0
- sknetwork/linalg/push.cpp +1771 -1155
- sknetwork/linalg/sparse_lowrank.py +1 -1
- sknetwork/ranking/betweenness.cp39-win_amd64.pyd +0 -0
- sknetwork/ranking/betweenness.cpp +565 -559
- sknetwork/topology/cliques.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/cliques.cpp +1731 -1112
- sknetwork/topology/core.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/core.cpp +1757 -1141
- sknetwork/topology/cycles.py +2 -2
- sknetwork/topology/minheap.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/minheap.cpp +689 -679
- sknetwork/topology/triangles.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/triangles.cpp +439 -434
- sknetwork/topology/weisfeiler_lehman_core.cp39-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.3.dist-info/licenses}/AUTHORS.rst +0 -0
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.3.dist-info/licenses}/LICENSE +0 -0
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.3.dist-info}/top_level.txt +0 -0
sknetwork/topology/triangles.cpp
CHANGED
|
@@ -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-ji5gyl3u\\overlay\\Lib\\site-packages\\numpy\\_core\\include"
|
|
12
12
|
],
|
|
13
13
|
"language": "c++",
|
|
14
14
|
"name": "sknetwork.topology.triangles",
|
|
@@ -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
|
|
@@ -1813,7 +1813,7 @@ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args,
|
|
|
1813
1813
|
#if !CYTHON_VECTORCALL
|
|
1814
1814
|
#if PY_VERSION_HEX >= 0x03080000
|
|
1815
1815
|
#include "frameobject.h"
|
|
1816
|
-
#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
1816
|
+
#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
|
|
1817
1817
|
#ifndef Py_BUILD_CORE
|
|
1818
1818
|
#define Py_BUILD_CORE 1
|
|
1819
1819
|
#endif
|
|
@@ -3357,7 +3357,7 @@ static PyObject *__pyx_pf_9sknetwork_8topology_9triangles_count_triangles(CYTHON
|
|
|
3357
3357
|
PyObject *__pyx_t_1 = NULL;
|
|
3358
3358
|
PyObject *__pyx_t_2 = NULL;
|
|
3359
3359
|
PyObject *__pyx_t_3 = NULL;
|
|
3360
|
-
int __pyx_t_4;
|
|
3360
|
+
unsigned int __pyx_t_4;
|
|
3361
3361
|
PyObject *__pyx_t_5 = NULL;
|
|
3362
3362
|
PyObject *__pyx_t_6 = NULL;
|
|
3363
3363
|
std::vector<int> __pyx_t_7;
|
|
@@ -3670,7 +3670,7 @@ static PyObject *__pyx_pf_9sknetwork_8topology_9triangles_2get_clustering_coeffi
|
|
|
3670
3670
|
PyObject *__pyx_t_1 = NULL;
|
|
3671
3671
|
PyObject *__pyx_t_2 = NULL;
|
|
3672
3672
|
PyObject *__pyx_t_3 = NULL;
|
|
3673
|
-
int __pyx_t_4;
|
|
3673
|
+
unsigned int __pyx_t_4;
|
|
3674
3674
|
PyObject *__pyx_t_5 = NULL;
|
|
3675
3675
|
PyObject *__pyx_t_6 = NULL;
|
|
3676
3676
|
int __pyx_lineno = 0;
|
|
@@ -7329,6 +7329,9 @@ static PyTypeObject __pyx_CyFunctionType_type = {
|
|
|
7329
7329
|
#if PY_VERSION_HEX >= 0x030C0000
|
|
7330
7330
|
0,
|
|
7331
7331
|
#endif
|
|
7332
|
+
#if PY_VERSION_HEX >= 0x030d00A4
|
|
7333
|
+
0,
|
|
7334
|
+
#endif
|
|
7332
7335
|
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
|
|
7333
7336
|
0,
|
|
7334
7337
|
#endif
|
|
@@ -7514,7 +7517,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
|
|
|
7514
7517
|
#include "compile.h"
|
|
7515
7518
|
#include "frameobject.h"
|
|
7516
7519
|
#include "traceback.h"
|
|
7517
|
-
#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
7520
|
+
#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
|
|
7518
7521
|
#ifndef Py_BUILD_CORE
|
|
7519
7522
|
#define Py_BUILD_CORE 1
|
|
7520
7523
|
#endif
|
|
@@ -7755,12 +7758,19 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
|
|
|
7755
7758
|
}
|
|
7756
7759
|
}
|
|
7757
7760
|
{
|
|
7758
|
-
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
7759
7761
|
unsigned char *bytes = (unsigned char *)&value;
|
|
7760
|
-
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX
|
|
7762
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
|
|
7763
|
+
if (is_unsigned) {
|
|
7764
|
+
return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
|
|
7765
|
+
} else {
|
|
7766
|
+
return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
|
|
7767
|
+
}
|
|
7768
|
+
#elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
|
|
7769
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
7761
7770
|
return _PyLong_FromByteArray(bytes, sizeof(int),
|
|
7762
7771
|
little, !is_unsigned);
|
|
7763
7772
|
#else
|
|
7773
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
7764
7774
|
PyObject *from_bytes, *result = NULL;
|
|
7765
7775
|
PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL;
|
|
7766
7776
|
from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
|
|
@@ -7810,245 +7820,239 @@ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
|
|
|
7810
7820
|
}
|
|
7811
7821
|
return (int) val;
|
|
7812
7822
|
}
|
|
7813
|
-
}
|
|
7823
|
+
}
|
|
7814
7824
|
#endif
|
|
7815
|
-
if (
|
|
7816
|
-
|
|
7825
|
+
if (unlikely(!PyLong_Check(x))) {
|
|
7826
|
+
int val;
|
|
7827
|
+
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
|
|
7828
|
+
if (!tmp) return (int) -1;
|
|
7829
|
+
val = __Pyx_PyInt_As_int(tmp);
|
|
7830
|
+
Py_DECREF(tmp);
|
|
7831
|
+
return val;
|
|
7832
|
+
}
|
|
7833
|
+
if (is_unsigned) {
|
|
7817
7834
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
}
|
|
7835
|
+
if (unlikely(__Pyx_PyLong_IsNeg(x))) {
|
|
7836
|
+
goto raise_neg_overflow;
|
|
7837
|
+
} else if (__Pyx_PyLong_IsCompact(x)) {
|
|
7838
|
+
__PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
|
|
7839
|
+
} else {
|
|
7840
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
7841
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
7842
|
+
switch (__Pyx_PyLong_DigitCount(x)) {
|
|
7843
|
+
case 2:
|
|
7844
|
+
if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
|
|
7845
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
7846
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7847
|
+
} else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) {
|
|
7848
|
+
return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
|
|
7833
7849
|
}
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7850
|
+
}
|
|
7851
|
+
break;
|
|
7852
|
+
case 3:
|
|
7853
|
+
if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
|
|
7854
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
7855
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7856
|
+
} else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) {
|
|
7857
|
+
return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
|
|
7842
7858
|
}
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7859
|
+
}
|
|
7860
|
+
break;
|
|
7861
|
+
case 4:
|
|
7862
|
+
if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
|
|
7863
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
7864
|
+
__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])))
|
|
7865
|
+
} else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) {
|
|
7866
|
+
return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
|
|
7851
7867
|
}
|
|
7852
|
-
|
|
7853
|
-
|
|
7868
|
+
}
|
|
7869
|
+
break;
|
|
7854
7870
|
}
|
|
7871
|
+
}
|
|
7855
7872
|
#endif
|
|
7856
7873
|
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7874
|
+
if (unlikely(Py_SIZE(x) < 0)) {
|
|
7875
|
+
goto raise_neg_overflow;
|
|
7876
|
+
}
|
|
7860
7877
|
#else
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7878
|
+
{
|
|
7879
|
+
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
7880
|
+
if (unlikely(result < 0))
|
|
7881
|
+
return (int) -1;
|
|
7882
|
+
if (unlikely(result == 1))
|
|
7883
|
+
goto raise_neg_overflow;
|
|
7884
|
+
}
|
|
7868
7885
|
#endif
|
|
7869
|
-
|
|
7870
|
-
|
|
7886
|
+
if ((sizeof(int) <= sizeof(unsigned long))) {
|
|
7887
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
|
|
7871
7888
|
#ifdef HAVE_LONG_LONG
|
|
7872
|
-
|
|
7873
|
-
|
|
7889
|
+
} else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) {
|
|
7890
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
|
|
7874
7891
|
#endif
|
|
7875
|
-
|
|
7876
|
-
|
|
7892
|
+
}
|
|
7893
|
+
} else {
|
|
7877
7894
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
}
|
|
7895
|
+
if (__Pyx_PyLong_IsCompact(x)) {
|
|
7896
|
+
__PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
|
|
7897
|
+
} else {
|
|
7898
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
7899
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
7900
|
+
switch (__Pyx_PyLong_SignedDigitCount(x)) {
|
|
7901
|
+
case -2:
|
|
7902
|
+
if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) {
|
|
7903
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
7904
|
+
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7905
|
+
} else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
|
|
7906
|
+
return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
7891
7907
|
}
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7908
|
+
}
|
|
7909
|
+
break;
|
|
7910
|
+
case 2:
|
|
7911
|
+
if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
|
|
7912
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
7913
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7914
|
+
} else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
|
|
7915
|
+
return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
7900
7916
|
}
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7917
|
+
}
|
|
7918
|
+
break;
|
|
7919
|
+
case -3:
|
|
7920
|
+
if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
|
|
7921
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
7922
|
+
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7923
|
+
} else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
|
|
7924
|
+
return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
7909
7925
|
}
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7926
|
+
}
|
|
7927
|
+
break;
|
|
7928
|
+
case 3:
|
|
7929
|
+
if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
|
|
7930
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
7931
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7932
|
+
} else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
|
|
7933
|
+
return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
7918
7934
|
}
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7935
|
+
}
|
|
7936
|
+
break;
|
|
7937
|
+
case -4:
|
|
7938
|
+
if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
|
|
7939
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
7940
|
+
__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])))
|
|
7941
|
+
} else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
|
|
7942
|
+
return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
7927
7943
|
}
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7944
|
+
}
|
|
7945
|
+
break;
|
|
7946
|
+
case 4:
|
|
7947
|
+
if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
|
|
7948
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
7949
|
+
__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])))
|
|
7950
|
+
} else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
|
|
7951
|
+
return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
7936
7952
|
}
|
|
7937
|
-
|
|
7938
|
-
|
|
7953
|
+
}
|
|
7954
|
+
break;
|
|
7939
7955
|
}
|
|
7956
|
+
}
|
|
7940
7957
|
#endif
|
|
7941
|
-
|
|
7942
|
-
|
|
7958
|
+
if ((sizeof(int) <= sizeof(long))) {
|
|
7959
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
|
|
7943
7960
|
#ifdef HAVE_LONG_LONG
|
|
7944
|
-
|
|
7945
|
-
|
|
7961
|
+
} else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) {
|
|
7962
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
|
|
7946
7963
|
#endif
|
|
7947
|
-
|
|
7964
|
+
}
|
|
7965
|
+
}
|
|
7966
|
+
{
|
|
7967
|
+
int val;
|
|
7968
|
+
int ret = -1;
|
|
7969
|
+
#if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
7970
|
+
Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
|
|
7971
|
+
x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
|
|
7972
|
+
if (unlikely(bytes_copied == -1)) {
|
|
7973
|
+
} else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
|
|
7974
|
+
goto raise_overflow;
|
|
7975
|
+
} else {
|
|
7976
|
+
ret = 0;
|
|
7977
|
+
}
|
|
7978
|
+
#elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
7979
|
+
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
7980
|
+
unsigned char *bytes = (unsigned char *)&val;
|
|
7981
|
+
ret = _PyLong_AsByteArray((PyLongObject *)x,
|
|
7982
|
+
bytes, sizeof(val),
|
|
7983
|
+
is_little, !is_unsigned);
|
|
7984
|
+
#else
|
|
7985
|
+
PyObject *v;
|
|
7986
|
+
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
7987
|
+
int bits, remaining_bits, is_negative = 0;
|
|
7988
|
+
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
7989
|
+
if (likely(PyLong_CheckExact(x))) {
|
|
7990
|
+
v = __Pyx_NewRef(x);
|
|
7991
|
+
} else {
|
|
7992
|
+
v = PyNumber_Long(x);
|
|
7993
|
+
if (unlikely(!v)) return (int) -1;
|
|
7994
|
+
assert(PyLong_CheckExact(v));
|
|
7948
7995
|
}
|
|
7949
7996
|
{
|
|
7950
|
-
int
|
|
7951
|
-
|
|
7952
|
-
#if PY_MAJOR_VERSION < 3
|
|
7953
|
-
if (likely(v) && !PyLong_Check(v)) {
|
|
7954
|
-
PyObject *tmp = v;
|
|
7955
|
-
v = PyNumber_Long(tmp);
|
|
7956
|
-
Py_DECREF(tmp);
|
|
7957
|
-
}
|
|
7958
|
-
#endif
|
|
7959
|
-
if (likely(v)) {
|
|
7960
|
-
int ret = -1;
|
|
7961
|
-
#if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
7962
|
-
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
7963
|
-
unsigned char *bytes = (unsigned char *)&val;
|
|
7964
|
-
ret = _PyLong_AsByteArray((PyLongObject *)v,
|
|
7965
|
-
bytes, sizeof(val),
|
|
7966
|
-
is_little, !is_unsigned);
|
|
7967
|
-
#else
|
|
7968
|
-
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
7969
|
-
int bits, remaining_bits, is_negative = 0;
|
|
7970
|
-
long idigit;
|
|
7971
|
-
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
7972
|
-
if (unlikely(!PyLong_CheckExact(v))) {
|
|
7973
|
-
PyObject *tmp = v;
|
|
7974
|
-
v = PyNumber_Long(v);
|
|
7975
|
-
assert(PyLong_CheckExact(v));
|
|
7976
|
-
Py_DECREF(tmp);
|
|
7977
|
-
if (unlikely(!v)) return (int) -1;
|
|
7978
|
-
}
|
|
7979
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
7980
|
-
if (Py_SIZE(x) == 0)
|
|
7981
|
-
return (int) 0;
|
|
7982
|
-
is_negative = Py_SIZE(x) < 0;
|
|
7983
|
-
#else
|
|
7984
|
-
{
|
|
7985
|
-
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
7986
|
-
if (unlikely(result < 0))
|
|
7987
|
-
return (int) -1;
|
|
7988
|
-
is_negative = result == 1;
|
|
7989
|
-
}
|
|
7990
|
-
#endif
|
|
7991
|
-
if (is_unsigned && unlikely(is_negative)) {
|
|
7992
|
-
goto raise_neg_overflow;
|
|
7993
|
-
} else if (is_negative) {
|
|
7994
|
-
stepval = PyNumber_Invert(v);
|
|
7995
|
-
if (unlikely(!stepval))
|
|
7996
|
-
return (int) -1;
|
|
7997
|
-
} else {
|
|
7998
|
-
stepval = __Pyx_NewRef(v);
|
|
7999
|
-
}
|
|
8000
|
-
val = (int) 0;
|
|
8001
|
-
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
8002
|
-
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
8003
|
-
for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
|
|
8004
|
-
PyObject *tmp, *digit;
|
|
8005
|
-
digit = PyNumber_And(stepval, mask);
|
|
8006
|
-
if (unlikely(!digit)) goto done;
|
|
8007
|
-
idigit = PyLong_AsLong(digit);
|
|
8008
|
-
Py_DECREF(digit);
|
|
8009
|
-
if (unlikely(idigit < 0)) goto done;
|
|
8010
|
-
tmp = PyNumber_Rshift(stepval, shift);
|
|
8011
|
-
if (unlikely(!tmp)) goto done;
|
|
8012
|
-
Py_DECREF(stepval); stepval = tmp;
|
|
8013
|
-
val |= ((int) idigit) << bits;
|
|
8014
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
8015
|
-
if (Py_SIZE(stepval) == 0)
|
|
8016
|
-
goto unpacking_done;
|
|
8017
|
-
#endif
|
|
8018
|
-
}
|
|
8019
|
-
idigit = PyLong_AsLong(stepval);
|
|
8020
|
-
if (unlikely(idigit < 0)) goto done;
|
|
8021
|
-
remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
8022
|
-
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
8023
|
-
goto raise_overflow;
|
|
8024
|
-
val |= ((int) idigit) << bits;
|
|
8025
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
8026
|
-
unpacking_done:
|
|
8027
|
-
#endif
|
|
8028
|
-
if (!is_unsigned) {
|
|
8029
|
-
if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
|
|
8030
|
-
goto raise_overflow;
|
|
8031
|
-
if (is_negative)
|
|
8032
|
-
val = ~val;
|
|
8033
|
-
}
|
|
8034
|
-
ret = 0;
|
|
8035
|
-
done:
|
|
8036
|
-
Py_XDECREF(shift);
|
|
8037
|
-
Py_XDECREF(mask);
|
|
8038
|
-
Py_XDECREF(stepval);
|
|
8039
|
-
#endif
|
|
7997
|
+
int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
|
|
7998
|
+
if (unlikely(result < 0)) {
|
|
8040
7999
|
Py_DECREF(v);
|
|
8041
|
-
|
|
8042
|
-
return val;
|
|
8000
|
+
return (int) -1;
|
|
8043
8001
|
}
|
|
8044
|
-
|
|
8002
|
+
is_negative = result == 1;
|
|
8045
8003
|
}
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8004
|
+
if (is_unsigned && unlikely(is_negative)) {
|
|
8005
|
+
Py_DECREF(v);
|
|
8006
|
+
goto raise_neg_overflow;
|
|
8007
|
+
} else if (is_negative) {
|
|
8008
|
+
stepval = PyNumber_Invert(v);
|
|
8009
|
+
Py_DECREF(v);
|
|
8010
|
+
if (unlikely(!stepval))
|
|
8011
|
+
return (int) -1;
|
|
8012
|
+
} else {
|
|
8013
|
+
stepval = v;
|
|
8014
|
+
}
|
|
8015
|
+
v = NULL;
|
|
8016
|
+
val = (int) 0;
|
|
8017
|
+
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
8018
|
+
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
8019
|
+
for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
|
|
8020
|
+
PyObject *tmp, *digit;
|
|
8021
|
+
long idigit;
|
|
8022
|
+
digit = PyNumber_And(stepval, mask);
|
|
8023
|
+
if (unlikely(!digit)) goto done;
|
|
8024
|
+
idigit = PyLong_AsLong(digit);
|
|
8025
|
+
Py_DECREF(digit);
|
|
8026
|
+
if (unlikely(idigit < 0)) goto done;
|
|
8027
|
+
val |= ((int) idigit) << bits;
|
|
8028
|
+
tmp = PyNumber_Rshift(stepval, shift);
|
|
8029
|
+
if (unlikely(!tmp)) goto done;
|
|
8030
|
+
Py_DECREF(stepval); stepval = tmp;
|
|
8031
|
+
}
|
|
8032
|
+
Py_DECREF(shift); shift = NULL;
|
|
8033
|
+
Py_DECREF(mask); mask = NULL;
|
|
8034
|
+
{
|
|
8035
|
+
long idigit = PyLong_AsLong(stepval);
|
|
8036
|
+
if (unlikely(idigit < 0)) goto done;
|
|
8037
|
+
remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
8038
|
+
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
8039
|
+
goto raise_overflow;
|
|
8040
|
+
val |= ((int) idigit) << bits;
|
|
8041
|
+
}
|
|
8042
|
+
if (!is_unsigned) {
|
|
8043
|
+
if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
|
|
8044
|
+
goto raise_overflow;
|
|
8045
|
+
if (is_negative)
|
|
8046
|
+
val = ~val;
|
|
8047
|
+
}
|
|
8048
|
+
ret = 0;
|
|
8049
|
+
done:
|
|
8050
|
+
Py_XDECREF(shift);
|
|
8051
|
+
Py_XDECREF(mask);
|
|
8052
|
+
Py_XDECREF(stepval);
|
|
8053
|
+
#endif
|
|
8054
|
+
if (unlikely(ret))
|
|
8055
|
+
return (int) -1;
|
|
8052
8056
|
return val;
|
|
8053
8057
|
}
|
|
8054
8058
|
raise_overflow:
|
|
@@ -8092,12 +8096,19 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
|
|
|
8092
8096
|
}
|
|
8093
8097
|
}
|
|
8094
8098
|
{
|
|
8095
|
-
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
8096
8099
|
unsigned char *bytes = (unsigned char *)&value;
|
|
8097
|
-
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX
|
|
8100
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
|
|
8101
|
+
if (is_unsigned) {
|
|
8102
|
+
return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
|
|
8103
|
+
} else {
|
|
8104
|
+
return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
|
|
8105
|
+
}
|
|
8106
|
+
#elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
|
|
8107
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
8098
8108
|
return _PyLong_FromByteArray(bytes, sizeof(long),
|
|
8099
8109
|
little, !is_unsigned);
|
|
8100
8110
|
#else
|
|
8111
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
8101
8112
|
PyObject *from_bytes, *result = NULL;
|
|
8102
8113
|
PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL;
|
|
8103
8114
|
from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
|
|
@@ -8163,245 +8174,239 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
|
|
|
8163
8174
|
}
|
|
8164
8175
|
return (long) val;
|
|
8165
8176
|
}
|
|
8166
|
-
}
|
|
8177
|
+
}
|
|
8167
8178
|
#endif
|
|
8168
|
-
if (
|
|
8169
|
-
|
|
8179
|
+
if (unlikely(!PyLong_Check(x))) {
|
|
8180
|
+
long val;
|
|
8181
|
+
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
|
|
8182
|
+
if (!tmp) return (long) -1;
|
|
8183
|
+
val = __Pyx_PyInt_As_long(tmp);
|
|
8184
|
+
Py_DECREF(tmp);
|
|
8185
|
+
return val;
|
|
8186
|
+
}
|
|
8187
|
+
if (is_unsigned) {
|
|
8170
8188
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
}
|
|
8189
|
+
if (unlikely(__Pyx_PyLong_IsNeg(x))) {
|
|
8190
|
+
goto raise_neg_overflow;
|
|
8191
|
+
} else if (__Pyx_PyLong_IsCompact(x)) {
|
|
8192
|
+
__PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
|
|
8193
|
+
} else {
|
|
8194
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
8195
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
8196
|
+
switch (__Pyx_PyLong_DigitCount(x)) {
|
|
8197
|
+
case 2:
|
|
8198
|
+
if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
|
|
8199
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
8200
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8201
|
+
} else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) {
|
|
8202
|
+
return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
|
|
8186
8203
|
}
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8204
|
+
}
|
|
8205
|
+
break;
|
|
8206
|
+
case 3:
|
|
8207
|
+
if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
|
|
8208
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
8209
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8210
|
+
} else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) {
|
|
8211
|
+
return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
|
|
8195
8212
|
}
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8213
|
+
}
|
|
8214
|
+
break;
|
|
8215
|
+
case 4:
|
|
8216
|
+
if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
|
|
8217
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
8218
|
+
__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])))
|
|
8219
|
+
} else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) {
|
|
8220
|
+
return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
|
|
8204
8221
|
}
|
|
8205
|
-
|
|
8206
|
-
|
|
8222
|
+
}
|
|
8223
|
+
break;
|
|
8207
8224
|
}
|
|
8225
|
+
}
|
|
8208
8226
|
#endif
|
|
8209
8227
|
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8228
|
+
if (unlikely(Py_SIZE(x) < 0)) {
|
|
8229
|
+
goto raise_neg_overflow;
|
|
8230
|
+
}
|
|
8213
8231
|
#else
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8232
|
+
{
|
|
8233
|
+
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
8234
|
+
if (unlikely(result < 0))
|
|
8235
|
+
return (long) -1;
|
|
8236
|
+
if (unlikely(result == 1))
|
|
8237
|
+
goto raise_neg_overflow;
|
|
8238
|
+
}
|
|
8221
8239
|
#endif
|
|
8222
|
-
|
|
8223
|
-
|
|
8240
|
+
if ((sizeof(long) <= sizeof(unsigned long))) {
|
|
8241
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
|
|
8224
8242
|
#ifdef HAVE_LONG_LONG
|
|
8225
|
-
|
|
8226
|
-
|
|
8243
|
+
} else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) {
|
|
8244
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
|
|
8227
8245
|
#endif
|
|
8228
|
-
|
|
8229
|
-
|
|
8246
|
+
}
|
|
8247
|
+
} else {
|
|
8230
8248
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
}
|
|
8249
|
+
if (__Pyx_PyLong_IsCompact(x)) {
|
|
8250
|
+
__PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
|
|
8251
|
+
} else {
|
|
8252
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
8253
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
8254
|
+
switch (__Pyx_PyLong_SignedDigitCount(x)) {
|
|
8255
|
+
case -2:
|
|
8256
|
+
if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) {
|
|
8257
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
8258
|
+
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8259
|
+
} else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
|
|
8260
|
+
return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
8244
8261
|
}
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8262
|
+
}
|
|
8263
|
+
break;
|
|
8264
|
+
case 2:
|
|
8265
|
+
if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
|
|
8266
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
8267
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8268
|
+
} else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
|
|
8269
|
+
return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
8253
8270
|
}
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8271
|
+
}
|
|
8272
|
+
break;
|
|
8273
|
+
case -3:
|
|
8274
|
+
if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
|
|
8275
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
8276
|
+
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8277
|
+
} else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
|
|
8278
|
+
return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
8262
8279
|
}
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8280
|
+
}
|
|
8281
|
+
break;
|
|
8282
|
+
case 3:
|
|
8283
|
+
if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
|
|
8284
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
8285
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8286
|
+
} else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
|
|
8287
|
+
return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
8271
8288
|
}
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8289
|
+
}
|
|
8290
|
+
break;
|
|
8291
|
+
case -4:
|
|
8292
|
+
if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
|
|
8293
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
8294
|
+
__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])))
|
|
8295
|
+
} else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
|
|
8296
|
+
return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
8280
8297
|
}
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8298
|
+
}
|
|
8299
|
+
break;
|
|
8300
|
+
case 4:
|
|
8301
|
+
if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
|
|
8302
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
8303
|
+
__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])))
|
|
8304
|
+
} else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
|
|
8305
|
+
return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
8289
8306
|
}
|
|
8290
|
-
|
|
8291
|
-
|
|
8307
|
+
}
|
|
8308
|
+
break;
|
|
8292
8309
|
}
|
|
8310
|
+
}
|
|
8293
8311
|
#endif
|
|
8294
|
-
|
|
8295
|
-
|
|
8312
|
+
if ((sizeof(long) <= sizeof(long))) {
|
|
8313
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
|
|
8296
8314
|
#ifdef HAVE_LONG_LONG
|
|
8297
|
-
|
|
8298
|
-
|
|
8315
|
+
} else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) {
|
|
8316
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
|
|
8299
8317
|
#endif
|
|
8300
|
-
|
|
8318
|
+
}
|
|
8319
|
+
}
|
|
8320
|
+
{
|
|
8321
|
+
long val;
|
|
8322
|
+
int ret = -1;
|
|
8323
|
+
#if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
8324
|
+
Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
|
|
8325
|
+
x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
|
|
8326
|
+
if (unlikely(bytes_copied == -1)) {
|
|
8327
|
+
} else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
|
|
8328
|
+
goto raise_overflow;
|
|
8329
|
+
} else {
|
|
8330
|
+
ret = 0;
|
|
8331
|
+
}
|
|
8332
|
+
#elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
8333
|
+
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
8334
|
+
unsigned char *bytes = (unsigned char *)&val;
|
|
8335
|
+
ret = _PyLong_AsByteArray((PyLongObject *)x,
|
|
8336
|
+
bytes, sizeof(val),
|
|
8337
|
+
is_little, !is_unsigned);
|
|
8338
|
+
#else
|
|
8339
|
+
PyObject *v;
|
|
8340
|
+
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
8341
|
+
int bits, remaining_bits, is_negative = 0;
|
|
8342
|
+
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
8343
|
+
if (likely(PyLong_CheckExact(x))) {
|
|
8344
|
+
v = __Pyx_NewRef(x);
|
|
8345
|
+
} else {
|
|
8346
|
+
v = PyNumber_Long(x);
|
|
8347
|
+
if (unlikely(!v)) return (long) -1;
|
|
8348
|
+
assert(PyLong_CheckExact(v));
|
|
8301
8349
|
}
|
|
8302
8350
|
{
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
#if PY_MAJOR_VERSION < 3
|
|
8306
|
-
if (likely(v) && !PyLong_Check(v)) {
|
|
8307
|
-
PyObject *tmp = v;
|
|
8308
|
-
v = PyNumber_Long(tmp);
|
|
8309
|
-
Py_DECREF(tmp);
|
|
8310
|
-
}
|
|
8311
|
-
#endif
|
|
8312
|
-
if (likely(v)) {
|
|
8313
|
-
int ret = -1;
|
|
8314
|
-
#if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
8315
|
-
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
8316
|
-
unsigned char *bytes = (unsigned char *)&val;
|
|
8317
|
-
ret = _PyLong_AsByteArray((PyLongObject *)v,
|
|
8318
|
-
bytes, sizeof(val),
|
|
8319
|
-
is_little, !is_unsigned);
|
|
8320
|
-
#else
|
|
8321
|
-
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
8322
|
-
int bits, remaining_bits, is_negative = 0;
|
|
8323
|
-
long idigit;
|
|
8324
|
-
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
8325
|
-
if (unlikely(!PyLong_CheckExact(v))) {
|
|
8326
|
-
PyObject *tmp = v;
|
|
8327
|
-
v = PyNumber_Long(v);
|
|
8328
|
-
assert(PyLong_CheckExact(v));
|
|
8329
|
-
Py_DECREF(tmp);
|
|
8330
|
-
if (unlikely(!v)) return (long) -1;
|
|
8331
|
-
}
|
|
8332
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
8333
|
-
if (Py_SIZE(x) == 0)
|
|
8334
|
-
return (long) 0;
|
|
8335
|
-
is_negative = Py_SIZE(x) < 0;
|
|
8336
|
-
#else
|
|
8337
|
-
{
|
|
8338
|
-
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
8339
|
-
if (unlikely(result < 0))
|
|
8340
|
-
return (long) -1;
|
|
8341
|
-
is_negative = result == 1;
|
|
8342
|
-
}
|
|
8343
|
-
#endif
|
|
8344
|
-
if (is_unsigned && unlikely(is_negative)) {
|
|
8345
|
-
goto raise_neg_overflow;
|
|
8346
|
-
} else if (is_negative) {
|
|
8347
|
-
stepval = PyNumber_Invert(v);
|
|
8348
|
-
if (unlikely(!stepval))
|
|
8349
|
-
return (long) -1;
|
|
8350
|
-
} else {
|
|
8351
|
-
stepval = __Pyx_NewRef(v);
|
|
8352
|
-
}
|
|
8353
|
-
val = (long) 0;
|
|
8354
|
-
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
8355
|
-
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
8356
|
-
for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
|
|
8357
|
-
PyObject *tmp, *digit;
|
|
8358
|
-
digit = PyNumber_And(stepval, mask);
|
|
8359
|
-
if (unlikely(!digit)) goto done;
|
|
8360
|
-
idigit = PyLong_AsLong(digit);
|
|
8361
|
-
Py_DECREF(digit);
|
|
8362
|
-
if (unlikely(idigit < 0)) goto done;
|
|
8363
|
-
tmp = PyNumber_Rshift(stepval, shift);
|
|
8364
|
-
if (unlikely(!tmp)) goto done;
|
|
8365
|
-
Py_DECREF(stepval); stepval = tmp;
|
|
8366
|
-
val |= ((long) idigit) << bits;
|
|
8367
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
8368
|
-
if (Py_SIZE(stepval) == 0)
|
|
8369
|
-
goto unpacking_done;
|
|
8370
|
-
#endif
|
|
8371
|
-
}
|
|
8372
|
-
idigit = PyLong_AsLong(stepval);
|
|
8373
|
-
if (unlikely(idigit < 0)) goto done;
|
|
8374
|
-
remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
8375
|
-
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
8376
|
-
goto raise_overflow;
|
|
8377
|
-
val |= ((long) idigit) << bits;
|
|
8378
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
8379
|
-
unpacking_done:
|
|
8380
|
-
#endif
|
|
8381
|
-
if (!is_unsigned) {
|
|
8382
|
-
if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
|
|
8383
|
-
goto raise_overflow;
|
|
8384
|
-
if (is_negative)
|
|
8385
|
-
val = ~val;
|
|
8386
|
-
}
|
|
8387
|
-
ret = 0;
|
|
8388
|
-
done:
|
|
8389
|
-
Py_XDECREF(shift);
|
|
8390
|
-
Py_XDECREF(mask);
|
|
8391
|
-
Py_XDECREF(stepval);
|
|
8392
|
-
#endif
|
|
8351
|
+
int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
|
|
8352
|
+
if (unlikely(result < 0)) {
|
|
8393
8353
|
Py_DECREF(v);
|
|
8394
|
-
|
|
8395
|
-
return val;
|
|
8354
|
+
return (long) -1;
|
|
8396
8355
|
}
|
|
8397
|
-
|
|
8356
|
+
is_negative = result == 1;
|
|
8398
8357
|
}
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8358
|
+
if (is_unsigned && unlikely(is_negative)) {
|
|
8359
|
+
Py_DECREF(v);
|
|
8360
|
+
goto raise_neg_overflow;
|
|
8361
|
+
} else if (is_negative) {
|
|
8362
|
+
stepval = PyNumber_Invert(v);
|
|
8363
|
+
Py_DECREF(v);
|
|
8364
|
+
if (unlikely(!stepval))
|
|
8365
|
+
return (long) -1;
|
|
8366
|
+
} else {
|
|
8367
|
+
stepval = v;
|
|
8368
|
+
}
|
|
8369
|
+
v = NULL;
|
|
8370
|
+
val = (long) 0;
|
|
8371
|
+
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
8372
|
+
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
8373
|
+
for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
|
|
8374
|
+
PyObject *tmp, *digit;
|
|
8375
|
+
long idigit;
|
|
8376
|
+
digit = PyNumber_And(stepval, mask);
|
|
8377
|
+
if (unlikely(!digit)) goto done;
|
|
8378
|
+
idigit = PyLong_AsLong(digit);
|
|
8379
|
+
Py_DECREF(digit);
|
|
8380
|
+
if (unlikely(idigit < 0)) goto done;
|
|
8381
|
+
val |= ((long) idigit) << bits;
|
|
8382
|
+
tmp = PyNumber_Rshift(stepval, shift);
|
|
8383
|
+
if (unlikely(!tmp)) goto done;
|
|
8384
|
+
Py_DECREF(stepval); stepval = tmp;
|
|
8385
|
+
}
|
|
8386
|
+
Py_DECREF(shift); shift = NULL;
|
|
8387
|
+
Py_DECREF(mask); mask = NULL;
|
|
8388
|
+
{
|
|
8389
|
+
long idigit = PyLong_AsLong(stepval);
|
|
8390
|
+
if (unlikely(idigit < 0)) goto done;
|
|
8391
|
+
remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
8392
|
+
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
8393
|
+
goto raise_overflow;
|
|
8394
|
+
val |= ((long) idigit) << bits;
|
|
8395
|
+
}
|
|
8396
|
+
if (!is_unsigned) {
|
|
8397
|
+
if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
|
|
8398
|
+
goto raise_overflow;
|
|
8399
|
+
if (is_negative)
|
|
8400
|
+
val = ~val;
|
|
8401
|
+
}
|
|
8402
|
+
ret = 0;
|
|
8403
|
+
done:
|
|
8404
|
+
Py_XDECREF(shift);
|
|
8405
|
+
Py_XDECREF(mask);
|
|
8406
|
+
Py_XDECREF(stepval);
|
|
8407
|
+
#endif
|
|
8408
|
+
if (unlikely(ret))
|
|
8409
|
+
return (long) -1;
|
|
8405
8410
|
return val;
|
|
8406
8411
|
}
|
|
8407
8412
|
raise_overflow:
|