Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/python3.14/longobject.h
1 #ifndef Py_LONGOBJECT_H 2 #define Py_LONGOBJECT_H 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 7 8 /* Long (arbitrary precision) integer object interface */ 9 10 // PyLong_Type is declared by object.h 11 12 #define PyLong_Check(op) \ 13 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS) 14 #define PyLong_CheckExact(op) Py_IS_TYPE((op), &PyLong_Type) 15 16 PyAPI_FUNC(PyObject *) PyLong_FromLong(long); 17 PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long); 18 PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t); 19 PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t); 20 PyAPI_FUNC(PyObject *) PyLong_FromDouble(double); 21 22 PyAPI_FUNC(long) PyLong_AsLong(PyObject *); 23 PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *); 24 PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *); 25 PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *); 26 PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); 27 PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); 28 29 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 30 PyAPI_FUNC(int) PyLong_AsInt(PyObject *); 31 #endif 32 33 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030e0000 34 PyAPI_FUNC(PyObject*) PyLong_FromInt32(int32_t value); 35 PyAPI_FUNC(PyObject*) PyLong_FromUInt32(uint32_t value); 36 PyAPI_FUNC(PyObject*) PyLong_FromInt64(int64_t value); 37 PyAPI_FUNC(PyObject*) PyLong_FromUInt64(uint64_t value); 38 39 PyAPI_FUNC(int) PyLong_AsInt32(PyObject *obj, int32_t *value); 40 PyAPI_FUNC(int) PyLong_AsUInt32(PyObject *obj, uint32_t *value); 41 PyAPI_FUNC(int) PyLong_AsInt64(PyObject *obj, int64_t *value); 42 PyAPI_FUNC(int) PyLong_AsUInt64(PyObject *obj, uint64_t *value); 43 44 #define Py_ASNATIVEBYTES_DEFAULTS -1 45 #define Py_ASNATIVEBYTES_BIG_ENDIAN 0 46 #define Py_ASNATIVEBYTES_LITTLE_ENDIAN 1 47 #define Py_ASNATIVEBYTES_NATIVE_ENDIAN 3 48 #define Py_ASNATIVEBYTES_UNSIGNED_BUFFER 4 49 #define Py_ASNATIVEBYTES_REJECT_NEGATIVE 8 50 #define Py_ASNATIVEBYTES_ALLOW_INDEX 16 51 52 /* PyLong_AsNativeBytes: Copy the integer value to a native variable. 53 buffer points to the first byte of the variable. 54 n_bytes is the number of bytes available in the buffer. Pass 0 to request 55 the required size for the value. 56 flags is a bitfield of the following flags: 57 * 1 - little endian 58 * 2 - native endian 59 * 4 - unsigned destination (e.g. don't reject copying 255 into one byte) 60 * 8 - raise an exception for negative inputs 61 * 16 - call __index__ on non-int types 62 If flags is -1 (all bits set), native endian is used, value truncation 63 behaves most like C (allows negative inputs and allow MSB set), and non-int 64 objects will raise a TypeError. 65 Big endian mode will write the most significant byte into the address 66 directly referenced by buffer; little endian will write the least significant 67 byte into that address. 68 69 If an exception is raised, returns a negative value. 70 Otherwise, returns the number of bytes that are required to store the value. 71 To check that the full value is represented, ensure that the return value is 72 equal or less than n_bytes. 73 All n_bytes are guaranteed to be written (unless an exception occurs), and 74 so ignoring a positive return value is the equivalent of a downcast in C. 75 In cases where the full value could not be represented, the returned value 76 may be larger than necessary - this function is not an accurate way to 77 calculate the bit length of an integer object. 78 */ 79 PyAPI_FUNC(Py_ssize_t) PyLong_AsNativeBytes(PyObject* v, void* buffer, 80 Py_ssize_t n_bytes, int flags); 81 82 /* PyLong_FromNativeBytes: Create an int value from a native integer 83 n_bytes is the number of bytes to read from the buffer. Passing 0 will 84 always produce the zero int. 85 PyLong_FromUnsignedNativeBytes always produces a non-negative int. 86 flags is the same as for PyLong_AsNativeBytes, but only supports selecting 87 the endianness or forcing an unsigned buffer. 88 89 Returns the int object, or NULL with an exception set. */ 90 PyAPI_FUNC(PyObject*) PyLong_FromNativeBytes(const void* buffer, size_t n_bytes, 91 int flags); 92 PyAPI_FUNC(PyObject*) PyLong_FromUnsignedNativeBytes(const void* buffer, 93 size_t n_bytes, int flags); 94 95 #endif 96 97 PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); 98 99 /* It may be useful in the future. I've added it in the PyInt -> PyLong 100 cleanup to keep the extra information. [CH] */ 101 #define PyLong_AS_LONG(op) PyLong_AsLong(op) 102 103 /* Issue #1983: pid_t can be longer than a C long on some systems */ 104 #if !defined(SIZEOF_PID_T) || SIZEOF_PID_T == SIZEOF_INT 105 #define _Py_PARSE_PID "i" 106 #define PyLong_FromPid PyLong_FromLong 107 # if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 108 # define PyLong_AsPid PyLong_AsInt 109 # elif SIZEOF_INT == SIZEOF_LONG 110 # define PyLong_AsPid PyLong_AsLong 111 # else 112 static inline int 113 PyLong_AsPid(PyObject *obj) 114 { 115 int overflow; 116 long result = PyLong_AsLongAndOverflow(obj, &overflow); 117 if (overflow || result > INT_MAX || result < INT_MIN) { 118 PyErr_SetString(PyExc_OverflowError, 119 "Python int too large to convert to C int"); 120 return -1; 121 } 122 return (int)result; 123 } 124 # endif 125 #elif SIZEOF_PID_T == SIZEOF_LONG 126 #define _Py_PARSE_PID "l" 127 #define PyLong_FromPid PyLong_FromLong 128 #define PyLong_AsPid PyLong_AsLong 129 #elif defined(SIZEOF_LONG_LONG) && SIZEOF_PID_T == SIZEOF_LONG_LONG 130 #define _Py_PARSE_PID "L" 131 #define PyLong_FromPid PyLong_FromLongLong 132 #define PyLong_AsPid PyLong_AsLongLong 133 #else 134 #error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)" 135 #endif /* SIZEOF_PID_T */ 136 137 #if SIZEOF_VOID_P == SIZEOF_INT 138 # define _Py_PARSE_INTPTR "i" 139 # define _Py_PARSE_UINTPTR "I" 140 #elif SIZEOF_VOID_P == SIZEOF_LONG 141 # define _Py_PARSE_INTPTR "l" 142 # define _Py_PARSE_UINTPTR "k" 143 #elif defined(SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG 144 # define _Py_PARSE_INTPTR "L" 145 # define _Py_PARSE_UINTPTR "K" 146 #else 147 # error "void* different in size from int, long and long long" 148 #endif /* SIZEOF_VOID_P */ 149 150 PyAPI_FUNC(double) PyLong_AsDouble(PyObject *); 151 PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *); 152 PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *); 153 154 PyAPI_FUNC(PyObject *) PyLong_FromLongLong(long long); 155 PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned long long); 156 PyAPI_FUNC(long long) PyLong_AsLongLong(PyObject *); 157 PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLong(PyObject *); 158 PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLongMask(PyObject *); 159 PyAPI_FUNC(long long) PyLong_AsLongLongAndOverflow(PyObject *, int *); 160 161 PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int); 162 163 /* These aren't really part of the int object, but they're handy. The 164 functions are in Python/mystrtoul.c. 165 */ 166 PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int); 167 PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int); 168 169 #ifndef Py_LIMITED_API 170 # define Py_CPYTHON_LONGOBJECT_H 171 # include "cpython/longobject.h" 172 # undef Py_CPYTHON_LONGOBJECT_H 173 #endif 174 175 #ifdef __cplusplus 176 } 177 #endif 178 #endif /* !Py_LONGOBJECT_H */