__Pyx_PyInt_From_int(int value)1 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
2 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3 #pragma GCC diagnostic push
4 #pragma GCC diagnostic ignored "-Wconversion"
5 #endif
6     const int neg_one = (int) -1, const_zero = (int) 0;
7 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
8 #pragma GCC diagnostic pop
9 #endif
10     const int is_unsigned = neg_one > const_zero;
11     if (is_unsigned) {
12         if (sizeof(int) < sizeof(long)) {
13             return PyInt_FromLong((long) value);
14         } else if (sizeof(int) <= sizeof(unsigned long)) {
15             return PyLong_FromUnsignedLong((unsigned long) value);
16 #ifdef HAVE_LONG_LONG
17         } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
18             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
19 #endif
20         }
21     } else {
22         if (sizeof(int) <= sizeof(long)) {
23             return PyInt_FromLong((long) value);
24 #ifdef HAVE_LONG_LONG
25         } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
26             return PyLong_FromLongLong((PY_LONG_LONG) value);
27 #endif
28         }
29     }
30     {
31         int one = 1; int little = (int)*(unsigned char *)&one;
32         unsigned char *bytes = (unsigned char *)&value;
33         return _PyLong_FromByteArray(bytes, sizeof(int),
34                                      little, !is_unsigned);
35     }
36 }
37 
38