8000 Implement support for the new PyLong struct layout in Py3.12a7. (GH-5… · cython/cython@781b087 · GitHub
[go: up one dir, main page]

Skip to content

Commit 781b087

Browse files
authored
Implement support for the new PyLong struct layout in Py3.12a7. (GH-5353)
See python/cpython#102464
1 parent 975bd86 commit 781b087

File tree

4 files changed

+133
-116
lines changed

4 files changed

+133
-116
lines changed

Cython/Utility/Builtins.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static PyObject *__Pyx_PyLong_AbsNeg(PyObject *num);/*proto*/
234234

235235
#define __Pyx_PyNumber_Absolute(x) \
236236
((likely(PyLong_CheckExact(x))) ? \
237-
(likely(Py_SIZE(x) >= 0) ? (Py_INCREF(x), (x)) : __Pyx_PyLong_AbsNeg(x)) : \
237+
(likely(__Pyx_PyLong_IsNonNeg(x)) ? (Py_INCREF(x), (x)) : __Pyx_PyLong_AbsNeg(x)) : \
238238
PyNumber_Absolute(x))
239239

240240
#else

Cython/Utility/Optimize.c

Lines changed: 53 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -979,14 +979,12 @@ static PyObject* __Pyx__PyNumber_PowerOf2(PyObject *two, PyObject *exp, PyObject
979979
#endif
980980
if (likely(PyLong_CheckExact(exp))) {
981981
#if CYTHON_USE_PYLONG_INTERNALS
982-
const Py_ssize_t size = Py_SIZE(exp);
983-
// tuned to optimise branch prediction
984-
if (likely(size == 1)) {
985-
shiftby = __Pyx_PyLong_Digits(exp)[0];
986-
} else if (size == 0) {
982+
if (__Pyx_PyLong_IsZero(exp)) {
987983
return PyInt_FromLong(1L);
988-
} else if (unlikely(size < 0)) {
984+
} else if (__Pyx_PyLong_IsNeg(exp)) {
989985
goto fallback;
986+
} else if (__Pyx_PyLong_IsCompact(exp)) {
987+
shiftby = __Pyx_PyLong_CompactValueUnsigned(exp);
990988
} else {
991989
shiftby = PyLong_AsSsize_t(exp);
992990
}
@@ -1062,21 +1060,18 @@ static CYTHON_INLINE {{c_ret_type}} __Pyx_PyInt_{{'' if ret_type.is_pyobject els
10621060
if (likely(PyLong_CheckExact({{pyval}}))) {
10631061
int unequal;
10641062
unsigned long uintval;
1065-
Py_ssize_t size = Py_SIZE({{pyval}});
1063+
Py_ssize_t size = __Pyx_PyLong_DigitCount({{pyval}});
10661064
const digit* digits = __Pyx_PyLong_Digits({{pyval}});
10671065
if (intval == 0) {
1068-
// == 0 => Py_SIZE(pyval) == 0
1069-
{{return_compare('size', '0', c_op)}}
1066+
{{return_compare('__Pyx_PyLong_IsZero(%s)' % pyval, '1', c_op)}}
10701067
} else if (intval < 0) {
1071-
// < 0 => Py_SIZE(pyval) < 0
1072-
if (size >= 0)
1068+
if (__Pyx_PyLong_IsNonNeg({{pyval}}))
10731069
{{return_false if op == 'Eq' else return_true}};
10741070
// both are negative => can use absolute values now.
10751071
intval = -intval;
1076-
size = -size;
10771072
} else {
10781073
// > 0 => Py_SIZE(pyval) > 0
1079-
if (size <= 0)
1074+
if (__Pyx_PyLong_IsNeg({{pyval}}))
10801075
{{return_false if op == 'Eq' else return_true}};
10811076
}
10821077
// After checking that the sign is the same (and excluding 0), now compare the absolute values.
@@ -1242,20 +1237,15 @@ static {{c_ret_type}} {{cfunc_name}}(PyObject *op1, PyObject *op2, long intval,
12421237
PY_LONG_LONG ll{{ival}}, llx;
12431238
#endif
12441239
{{endif}}
1245-
const digit* digits = __Pyx_PyLong_Digits({{pyval}});
1246-
const Py_ssize_t size = Py_SIZE({{pyval}});
12471240
{{if c_op == '&'}}
12481241
// special case for &-ing arbitrarily large numbers with known single digit operands
12491242
if ((intval & PyLong_MASK) == intval) {
1250-
long result = 0;
1251-
if(likely(size)) {
1252 F438 -
result = intval & (likely(size>0) ? digits[0] : (PyLong_MASK - digits[0] + 1));
1253-
}
1243+
long result = intval & (long) __Pyx_PyLong_CompactValue({{pyval}});
12541244
return PyLong_FromLong(result);
12551245
}
12561246
{{endif}}
12571247
// special cases for 0: + - * % / // | ^ & >> <<
1258-
if (unlikely(size == 0)) {
1248+
if (unlikely(__Pyx_PyLong_IsZero({{pyval}}))) {
12591249
{{if order == 'CObj' and c_op in '%/'}}
12601250
// division by zero!
12611251
{{zerodiv_check('0')}}
@@ -1277,10 +1267,11 @@ static {{c_ret_type}} {{cfunc_name}}(PyObject *op1, PyObject *op2, long intval,
12771267
{{endif}}
12781268
}
12791269
// handle most common case first to avoid indirect branch and optimise branch prediction
1280-
if (likely(__Pyx_sst_abs(size) <= 1)) {
1281-
{{ival}} = likely(size) ? digits[0] : 0;
1282-
if (size == -1) {{ival}} = -{{ival}};
1270+
if (likely(__Pyx_PyLong_IsCompact({{pyval}}))) {
1271+
{{ival}} = __Pyx_PyLong_CompactValue({{pyval}});
12831272
} else {
1273+
const digit* digits = __Pyx_PyLong_Digits({{pyval}});
1274+
const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount({{pyval}});
12841275
switch (size) {
12851276
{{for _size in range(2, 5)}}
12861277
{{for _case in (-_size, _size)}}
@@ -1337,7 +1328,7 @@ static {{c_ret_type}} {{cfunc_name}}(PyObject *op1, PyObject *op2, long intval,
13371328
x += ((x != 0) & ((x ^ b) < 0)) * b;
13381329
{{elif op == 'TrueDivide'}}
13391330
if ((8 * sizeof(long) <= 53 || likely(labs({{ival}}) <= ((PY_LONG_LONG)1 << 53)))
1340-
|| __Pyx_sst_abs(size) <= 52 / PyLong_SHIFT) {
1331+
|| __Pyx_PyLong_DigitCount({{pyval}}) <= 52 / PyLong_SHIFT) {
13411332
return PyFloat_FromDouble((double)a / (double)b);
13421333
}
13431334
return PyLong_Type.tp_as_number->nb_{{slot_name}}(op1, op2);
@@ -1497,46 +1488,50 @@ static {{c_ret_type}} {{cfunc_name}}(PyObject *op1, PyObject *op2, double floatv
14971488

14981489
if (likely(PyLong_CheckExact({{pyval}}))) {
14991490
#if CYTHON_USE_PYLONG_INTERNALS
1500-
const digit* digits = __Pyx_PyLong_Digits({{pyval}});
1501-
const Py_ssize_t size = Py_SIZE({{pyval}});
1502-
switch (size) {
1503-
case 0: {{fval}} = 0.0; {{zerodiv_check(fval)}} break;
1504-
case -1: {{fval}} = -(double) digits[0]; break;
1505-
case 1: {{fval}} = (double) digits[0]; break;
1506-
{{for _size in (2, 3, 4)}}
1507-
case -{{_size}}:
1508-
case {{_size}}:
1509-
if (8 * sizeof(unsigned long) > {{_size}} * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || ({{_size-1}} * PyLong_SHIFT < 53))) {
1510-
{{fval}} = (double) {{pylong_join(_size, 'digits')}};
1511-
// let CPython do its own float rounding from 2**53 on (max. consecutive integer in double float)
1512-
if ((8 * sizeof(unsigned long) < 53) || ({{_size}} * PyLong_SHIFT < 53) || ({{fval}} < (double) ((PY_LONG_LONG)1 << 53))) {
1513-
if (size == {{-_size}})
1514-
{{fval}} = -{{fval}};
1515-
break;
1491+
if (__Pyx_PyLong_IsZero({{pyval}})) {
1492+
{{fval}} = 0.0;
1493+
{{zerodiv_check(fval)}}
1494+
} else if (__Pyx_PyLong_IsCompact({{pyval}})) {
1495+
{{fval}} = (double) __Pyx_PyLong_CompactValue({{pyval}});
1496+
} else {
1497+
const digit* digits = __Pyx_PyLong_Digits({{pyval}});
1498+
const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount({{pyval}});
1499+
switch (size) {
1500+
{{for _size in (2, 3, 4)}}
1501+
case -{{_size}}:
1502+
case {{_size}}:
1503+
if (8 * sizeof(unsigned long) > {{_size}} * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || ({{_size-1}} * PyLong_SHIFT < 53))) {
1504+
{{fval}} = (double) {{pylong_join(_size, 'digits')}};
1505+
// let CPython do its own float rounding from 2**53 on (max. consecutive integer in double float)
1506+
if ((8 * sizeof(unsigned long) < 53) || ({{_size}} * PyLong_SHIFT < 53) || ({{fval}} < (double) ((PY_LONG_LONG)1 << 53))) {
1507+
if (size == {{-_size}})
1508+
{{fval}} = -{{fval}};
1509+
break;
1510+
}
15161511
}
1517-
}
1518-
// Fall through if size doesn't fit safely into a double anymore.
1519-
// It may not be obvious that this is a safe fall-through given the "fval < 2**53"
1520-
// check above. However, the number of digits that CPython uses for a given PyLong
1521-
// value is minimal, and together with the "(size-1) * SHIFT < 53" check above,
1522-
// this should make it safe.
1523-
CYTHON_FALLTHROUGH;
1524-
{{endfor}}
1525-
default:
1512+
// Fall through if size doesn't fit safely into a double anymore.
1513+
// It may not be obvious that this is a safe fall-through given the "fval < 2**53"
1514+
// check above. However, the number of digits that CPython uses for a given PyLong
1515+
// value is minimal, and together with the "(size-1) * SHIFT < 53" check above,
1516+
// this should make it safe.
1517+
CYTHON_FALLTHROUGH;
1518+
{{endfor}}
1519+
default:
15261520
#endif
15271521
{{if op in ('Eq', 'Ne')}}
1528-
return {{'' if ret_type.is_pyobject else '__Pyx_PyObject_IsTrueAndDecref'}}(
1529-
PyFloat_Type.tp_richcompare({{'op1, op2' if order == 'CObj' else 'op2, op1'}}, Py_{{op.upper()}}));
1522+
return {{'' if ret_type.is_pyobject else '__Pyx_PyObject_IsTrueAndDecref'}}(
1523+
PyFloat_Type.tp_richcompare({{'op1, op2' if order == 'CObj' else 'op2, op1'}}, Py_{{op.upper()}}));
15301524
{{else}}
1531-
{{fval}} = PyLong_AsDouble({{pyval}});
1532-
if (unlikely({{fval}} == -1.0 && PyErr_Occurred())) return NULL;
1533-
{{if zerodiv_check(fval)}}
1534-
#if !CYTHON_USE_PYLONG_INTERNALS
1535-
{{zerodiv_check(fval)}}
1536-
#endif
1537-
{{endif}}
1525+
{{fval}} = PyLong_AsDouble({{pyval}});
1526+
if (unlikely({{fval}} == -1.0 && PyErr_Occurred())) return NULL;
1527+
{{if zerodiv_check(fval)}}
1528+
#if !CYTHON_USE_PYLONG_INTERNALS
1529+
{{zerodiv_check(fval)}}
1530+
#endif
1531+
{{endif}}
15381532
{{endif}}
15391533
#if CYTHON_USE_PYLONG_INTERNALS
1534+
}
15401535
}
15411536
#endif
15421537
} else {

Cython/Utility/StringTools.c

Lines changed: 3 additions & 1241 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,11 +1061,11 @@ static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyO
10611061
} else
10621062
#endif
10631063
#if CYTHON_USE_PYLONG_INTERNALS
1064-
if (likely(PyLong_CheckExact(value)) && likely(Py_SIZE(value) == 1 || Py_SIZE(value) == 0)) {
1065-
if (Py_SIZE(value) == 0) {
1064+
if (likely(PyLong_CheckExact(value)) && likely(__Pyx_PyLong_IsCompact(value))) {
1065+
if (__Pyx_PyLong_IsZero(value)) {
10661066
ival = 0;
10671067
} else {
1068-
ival = __Pyx_PyLong_Digits(value)[0];
1068+
ival = __Pyx_PyLong_CompactValue(value);
10691069
if (unlikely(ival > 255)) goto bad_range;
10701070
}
10711071
} else

Cython/Utility/TypeConversion.c

Lines changed: 76 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,33 @@ static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
130130
// string conversion work the same in all circumstances).
131131

132132
#if CYTHON_USE_PYLONG_INTERNALS
133+
#if PY_VERSION_HEX >= 0x030C00A7
134+
#define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & 3)
135+
#define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0)
136+
#define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x))
137+
#define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1)
138+
#define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0)
139+
#define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << 3)) // (2 << NON_SIZE_BITS)
140+
#define __Pyx_PyLong_CompactValue(x) ((1 - __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0])
141+
#define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0])
142+
#define __Pyx_PyLong_DigitCount(x) (((PyLongObject*)x)->long_value.lv_tag >> 3) // (>> NON_SIZE_BITS)
143+
#define __Pyx_PyLong_SignedDigitCount(x) \
144+
((1 - ((PyLongObject*)x)->long_value.lv_tag & 3) * (((PyLongObject*)x)->long_value.lv_tag >> 3)) // (>> NON_SIZE_BITS)
145+
#else // Py < 3.12
146+
#define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0)
147+
#define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0)
148+
#define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0)
149+
#define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0)
150+
#define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1)
151+
#define __Pyx_PyLong_CompactValue(x) \
152+
((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0]))
153+
#define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0])
154+
#define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x))
155+
#define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x)
156+
#endif
157+
158+
typedef sdigit __Pyx_compact_pylong;
159+
133160
#if PY_VERSION_HEX >= 0x030C00A5
134161
#define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit)
135162
#else
@@ -413,14 +440,12 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
413440
#endif
414441
if (likely(PyLong_CheckExact(b))) {
415442
#if CYTHON_USE_PYLONG_INTERNALS
416-
const digit* digits = __Pyx_PyLong_Digits(b);
417-
const Py_ssize_t size = Py_SIZE(b);
418443
// handle most common case first to avoid indirect branch and optimise branch prediction
419-
if (likely(__Pyx_sst_abs(size) <= 1)) {
420-
ival = likely(size) ? digits[0] : 0;
421-
if (size == -1) ival = -ival;
422-
return ival;
444+
if (likely(__Pyx_PyLong_IsCompact(b))) {
445+
return __Pyx_PyLong_CompactValue(b);
423446
} else {
447+
const digit* digits = __Pyx_PyLong_Digits(b);
448+
const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b);
424449
switch (size) {
425450
{{for _size in (2, 3, 4)}}
426451
{{for _case in (_size, -_size)}}
@@ -486,24 +511,12 @@ static CYTHON_INLINE PyObject* __Pyx__PyNumber_Float(PyObject* obj) {
486511
double val;
487512
if (PyLong_CheckExact(obj)) {
488513
#if CYTHON_USE_PYLONG_INTERNALS
489-
const digit* digits = __Pyx_PyLong_Digits(obj);
490-
switch (Py_SIZE(obj)) {
491-
case 0:
492-
val = 0.0;
493-
goto no_error;
494-
// single digit PyLong values always cast safely to double
495-
case 1:
496-
val = (double) digits[0];
497-
goto no_error;
498-
case -1:
499-
val = (double) - (sdigit) digits[0];
500-
goto no_error;
501-
default:
502-
val = PyLong_AsDouble(obj);
514+
if (likely(__Pyx_PyLong_IsCompact(obj))) {
515+
val = (double) __Pyx_PyLong_CompactValue(obj);
516+
goto no_error;
503517
}
504-
#else
505-
val = PyLong_AsDouble(obj);
506518
#endif
519+
val = PyLong_AsDouble(obj);
507520
} else if (PyUnicode_CheckExact(obj)) {
508521
val = __Pyx_PyUnicode_AsDouble(obj);
509522
} else if (PyBytes_CheckExact(obj)) {
@@ -976,24 +989,31 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) {
976989
if (likely(PyLong_Check(x))) {
977990
if (is_unsigned) {
978991
#if CYTHON_USE_PYLONG_INTERNALS
979-
const digit* digits = __Pyx_PyLong_Digits(x);
980-
switch (Py_SIZE(x)) {
981-
case 0: return ({{TYPE}}) 0;
982-
case 1: __PYX_VERIFY_RETURN_INT({{TYPE}}, digit, digits[0])
983-
{{for _size in (2, 3, 4)}}
984-
case {{_size}}:
985-
if ((8 * sizeof({{TYPE}}) > {{_size-1}} * PyLong_SHIFT)) {
986-
if ((8 * sizeof(unsigned long) > {{_size}} * PyLong_SHIFT)) {
987-
__PYX_VERIFY_RETURN_INT({{TYPE}}, unsigned long, {{pylong_join(_size, 'digits')}})
988-
} else if ((8 * sizeof({{TYPE}}) >= {{_size}} * PyLong_SHIFT)) {
989-
return ({{TYPE}}) {{pylong_join(_size, 'digits', TYPE)}};
992+
if (unlikely(__Pyx_PyLong_IsNeg(x))) {
993+
goto raise_neg_overflow;
994+
//} else if (__Pyx_PyLong_IsZero(x)) {
995+
// return ({{TYPE}}) 0;
996+
} else if (__Pyx_PyLong_IsCompact(x)) {
997+
__PYX_VERIFY_RETURN_INT({{TYPE}}, __Pyx_compact_pylong, __Pyx_PyLong_CompactValueUnsigned(x))
998+
} else {
999+
const digit* digits = __Pyx_PyLong_Digits(x);
1000+
assert(__Pyx_PyLong_DigitCount(x) > 1);
1001+
switch (__Pyx_PyLong_DigitCount(x)) {
1002+
{{for _size in (2, 3, 4)}}
1003+
case {{_size}}:
1004+
if ((8 * sizeof({{TYPE}}) > {{_size-1}} * PyLong_SHIFT)) {
1005+
if ((8 * sizeof(unsigned long) > {{_size}} * PyLong_SHIFT)) {
1006+
__PYX_VERIFY_RETURN_INT({{TYPE}}, unsigned long, {{pylong_join(_size, 'digits')}})
1007+
} else if ((8 * sizeof({{TYPE}}) >= {{_size}} * PyLong_SHIFT)) {
1008+
return ({{TYPE}}) {{pylong_join(_size, 'digits', TYPE)}};
1009+
}
9901010
}
991-
}
992-
break;
993-
{{endfor}}
1011+
break;
1012+
{{endfor}}
1013+
}
9941014
}
9951015
#endif
996-
#if CYTHON_COMPILING_IN_CPYTHON
1016+
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
9971017
if (unlikely(Py_SIZE(x) < 0)) {
9981018
goto raise_neg_overflow;
9991019
}
@@ -1017,24 +1037,26 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) {
10171037
} else {
10181038
// signed
10191039
#if CYTHON_USE_PYLONG_INTERNALS
1020-
const digit* digits = __Pyx_PyLong_Digits(x);
1021-
switch (Py_SIZE(x)) {
1022-
case 0: return ({{TYPE}}) 0;
1023-
case -1: __PYX_VERIFY_RETURN_INT({{TYPE}}, sdigit, (sdigit) (-(sdigit)digits[0]))
1024-
case 1: __PYX_VERIFY_RETURN_INT({{TYPE}}, digit, +digits[0])
1025-
{{for _size in (2, 3, 4)}}
1026-
{{for _case in (-_size, _size)}}
1027-
case {{_case}}:
1028-
if ((8 * sizeof({{TYPE}}){{' - 1' if _case < 0 else ''}} > {{_size-1}} * PyLong_SHIFT)) {
1029-
if ((8 * sizeof(unsigned long) > {{_size}} * PyLong_SHIFT)) {
1030-
__PYX_VERIFY_RETURN_INT({{TYPE}}, {{'long' if _case < 0 else 'unsigned long'}}, {{'-(long) ' if _case < 0 else ''}}{{pylong_join(_size, 'digits')}})
1031-
} else if ((8 * sizeof({{TYPE}}) - 1 > {{_size}} * PyLong_SHIFT)) {
1032-
return ({{TYPE}}) ({{'((%s)-1)*' % TYPE if _case < 0 else ''}}{{pylong_join(_size, 'digits', TYPE)}});
1040+
if (__Pyx_PyLong_IsCompact(x)) {
1041+
__PYX_VERIFY_RETURN_INT({{TYPE}}, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
1042+
} else {
1043+
const digit* digits = __Pyx_PyLong_Digits(x);
1044+
assert(__Pyx_PyLong_DigitCount(x) > 1);
1045+
switch (__Pyx_PyLong_SignedDigitCount(x)) {
1046+
{{for _size in (2, 3, 4)}}
1047+
{{for _case in (-_size, _size)}}
1048+
case {{_case}}:
1049+
if ((8 * sizeof({{TYPE}}){{' - 1' if _case < 0 else ''}} > {{_size-1}} * PyLong_SHIFT)) {
1050+
if ((8 * sizeof(unsigned long) > {{_size}} * PyLong_SHIFT)) {
1051+
__PYX_VERIFY_RETURN_INT({{TYPE}}, {{'long' if _case < 0 else 'unsigned long'}}, {{'-(long) ' if _case < 0 else ''}}{{pylong_join(_size, 'digits')}})
1052+
} else if ((8 * sizeof({{TYPE}}) - 1 > {{_size}} * PyLong_SHIFT)) {
1053+
return ({{TYPE}}) ({{'((%s)-1)*' % TYPE if _case < 0 else ''}}{{pylong_join(_size, 'digits', TYPE)}});
1054+
}
10331055
}
1034-
}
1035-
break;
1036-
{{endfor}}
1037-
{{endfor}}
1056+
break;
1057+
{{endfor}}
1058+
{{endfor}}
1059+
}
10381060
}
10391061
#endif
10401062
if ((sizeof({{TYPE}}) <= sizeof(long))) {

0 commit comments

Comments
 (0)
0