@@ -129,6 +129,14 @@ static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); |
129 | 129 | // __Pyx_PyNumber_Float is now in it's own section since it has dependencies (needed to make |
130 | 130 | // string conversion work the same in all circumstances) |
131 | 131 |
|
| 132 | +#if CYTHON_USE_PYLONG_INTERNALS |
| 133 | + #if PY_VERSION_HEX >= 0x030C00A5 |
| 134 | + #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit) |
| 135 | + #else |
| 136 | + #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit) |
| 137 | + #endif |
| 138 | +#endif |
| 139 | + |
132 | 140 | #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII |
133 | 141 | static int __Pyx_sys_getdefaultencoding_not_ascii; |
134 | 142 | static int __Pyx_init_sys_getdefaultencoding_params(void) { |
@@ -405,7 +413,7 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { |
405 | 413 | #endif |
406 | 414 | if (likely(PyLong_CheckExact(b))) { |
407 | 415 | #if CYTHON_USE_PYLONG_INTERNALS |
408 | | - const digit* digits = ((PyLongObject*)b)->ob_digit; |
| 416 | + const digit* digits = __Pyx_PyLong_Digits(b); |
409 | 417 | const Py_ssize_t size = Py_SIZE(b); |
410 | 418 | // handle most common case first to avoid indirect branch and optimise branch prediction |
411 | 419 | if (likely(__Pyx_sst_abs(size) <= 1)) { |
@@ -478,7 +486,7 @@ static CYTHON_INLINE PyObject* __Pyx__PyNumber_Float(PyObject* obj) { |
478 | 486 | double val; |
479 | 487 | if (PyLong_CheckExact(obj)) { |
480 | 488 | #if CYTHON_USE_PYLONG_INTERNALS |
481 | | - const digit* digits = ((PyLongObject*)obj)->ob_digit; |
| 489 | + const digit* digits = __Pyx_PyLong_Digits(obj); |
482 | 490 | switch (Py_SIZE(obj)) { |
483 | 491 | case 0: |
484 | 492 | val = 0.0; |
@@ -968,7 +976,7 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) { |
968 | 976 | if (likely(PyLong_Check(x))) { |
969 | 977 | if (is_unsigned) { |
970 | 978 | #if CYTHON_USE_PYLONG_INTERNALS |
971 | | - const digit* digits = ((PyLongObject*)x)->ob_digit; |
| 979 | + const digit* digits = __Pyx_PyLong_Digits(x); |
972 | 980 | switch (Py_SIZE(x)) { |
973 | 981 | case 0: return ({{TYPE}}) 0; |
974 | 982 | case 1: __PYX_VERIFY_RETURN_INT({{TYPE}}, digit, digits[0]) |
@@ -1009,7 +1017,7 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) { |
1009 | 1017 | } else { |
1010 | 1018 | // signed |
1011 | 1019 | #if CYTHON_USE_PYLONG_INTERNALS |
1012 | | - const digit* digits = ((PyLongObject*)x)->ob_digit; |
| 1020 | + const digit* digits = __Pyx_PyLong_Digits(x); |
1013 | 1021 | switch (Py_SIZE(x)) { |
1014 | 1022 | case 0: return ({{TYPE}}) 0; |
1015 | 1023 | case -1: __PYX_VERIFY_RETURN_INT({{TYPE}}, sdigit, (sdigit) (-(sdigit)digits[0])) |
|