return (%(type)s)-1;
}
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
- switch (Py_SIZE(x)) {
- case 0: return 0;
- case 1: return (%(type)s) ((PyLongObject*)x)->ob_digit[0];
+ if (sizeof(digit) <= sizeof(%(type)s)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return (%(type)s) ((PyLongObject*)x)->ob_digit[0];
+ }
}
#endif
return (%(type)s)PyLong_AsUnsigned%(TypeName)s(x);
} else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
- switch (Py_SIZE(x)) {
- case 0: return 0;
- case 1: return +(%(type)s) ((PyLongObject*)x)->ob_digit[0];
- case -1: return -(%(type)s) ((PyLongObject*)x)->ob_digit[0];
+ if (sizeof(digit) <= sizeof(%(type)s)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return +(%(type)s) ((PyLongObject*)x)->ob_digit[0];
+ case -1: return -(%(type)s) ((PyLongObject*)x)->ob_digit[0];
+ }
}
#endif
return (%(type)s)PyLong_As%(TypeName)s(x);