Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../usr/include/python3....
File: longobject.h
#ifndef Py_LONGOBJECT_H
[0] Fix | Delete
#define Py_LONGOBJECT_H
[1] Fix | Delete
#ifdef __cplusplus
[2] Fix | Delete
extern "C" {
[3] Fix | Delete
#endif
[4] Fix | Delete
[5] Fix | Delete
[6] Fix | Delete
/* Long (arbitrary precision) integer object interface */
[7] Fix | Delete
[8] Fix | Delete
typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */
[9] Fix | Delete
[10] Fix | Delete
PyAPI_DATA(PyTypeObject) PyLong_Type;
[11] Fix | Delete
[12] Fix | Delete
#define PyLong_Check(op) \
[13] Fix | Delete
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
[14] Fix | Delete
#define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type)
[15] Fix | Delete
[16] Fix | Delete
PyAPI_FUNC(PyObject *) PyLong_FromLong(long);
[17] Fix | Delete
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long);
[18] Fix | Delete
PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t);
[19] Fix | Delete
PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t);
[20] Fix | Delete
PyAPI_FUNC(PyObject *) PyLong_FromDouble(double);
[21] Fix | Delete
PyAPI_FUNC(long) PyLong_AsLong(PyObject *);
[22] Fix | Delete
PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *);
[23] Fix | Delete
PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *);
[24] Fix | Delete
PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *);
[25] Fix | Delete
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *);
[26] Fix | Delete
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);
[27] Fix | Delete
#ifndef Py_LIMITED_API
[28] Fix | Delete
PyAPI_FUNC(int) _PyLong_AsInt(PyObject *);
[29] Fix | Delete
#endif
[30] Fix | Delete
PyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
[31] Fix | Delete
[32] Fix | Delete
/* It may be useful in the future. I've added it in the PyInt -> PyLong
[33] Fix | Delete
cleanup to keep the extra information. [CH] */
[34] Fix | Delete
#define PyLong_AS_LONG(op) PyLong_AsLong(op)
[35] Fix | Delete
[36] Fix | Delete
/* Issue #1983: pid_t can be longer than a C long on some systems */
[37] Fix | Delete
#if !defined(SIZEOF_PID_T) || SIZEOF_PID_T == SIZEOF_INT
[38] Fix | Delete
#define _Py_PARSE_PID "i"
[39] Fix | Delete
#define PyLong_FromPid PyLong_FromLong
[40] Fix | Delete
#define PyLong_AsPid PyLong_AsLong
[41] Fix | Delete
#elif SIZEOF_PID_T == SIZEOF_LONG
[42] Fix | Delete
#define _Py_PARSE_PID "l"
[43] Fix | Delete
#define PyLong_FromPid PyLong_FromLong
[44] Fix | Delete
#define PyLong_AsPid PyLong_AsLong
[45] Fix | Delete
#elif defined(SIZEOF_LONG_LONG) && SIZEOF_PID_T == SIZEOF_LONG_LONG
[46] Fix | Delete
#define _Py_PARSE_PID "L"
[47] Fix | Delete
#define PyLong_FromPid PyLong_FromLongLong
[48] Fix | Delete
#define PyLong_AsPid PyLong_AsLongLong
[49] Fix | Delete
#else
[50] Fix | Delete
#error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)"
[51] Fix | Delete
#endif /* SIZEOF_PID_T */
[52] Fix | Delete
[53] Fix | Delete
#if SIZEOF_VOID_P == SIZEOF_INT
[54] Fix | Delete
# define _Py_PARSE_INTPTR "i"
[55] Fix | Delete
# define _Py_PARSE_UINTPTR "I"
[56] Fix | Delete
#elif SIZEOF_VOID_P == SIZEOF_LONG
[57] Fix | Delete
# define _Py_PARSE_INTPTR "l"
[58] Fix | Delete
# define _Py_PARSE_UINTPTR "k"
[59] Fix | Delete
#elif defined(SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG
[60] Fix | Delete
# define _Py_PARSE_INTPTR "L"
[61] Fix | Delete
# define _Py_PARSE_UINTPTR "K"
[62] Fix | Delete
#else
[63] Fix | Delete
# error "void* different in size from int, long and long long"
[64] Fix | Delete
#endif /* SIZEOF_VOID_P */
[65] Fix | Delete
[66] Fix | Delete
/* Used by Python/mystrtoul.c, _PyBytes_FromHex(),
[67] Fix | Delete
_PyBytes_DecodeEscapeRecode(), etc. */
[68] Fix | Delete
#ifndef Py_LIMITED_API
[69] Fix | Delete
PyAPI_DATA(unsigned char) _PyLong_DigitValue[256];
[70] Fix | Delete
#endif
[71] Fix | Delete
[72] Fix | Delete
/* _PyLong_Frexp returns a double x and an exponent e such that the
[73] Fix | Delete
true value is approximately equal to x * 2**e. e is >= 0. x is
[74] Fix | Delete
0.0 if and only if the input is 0 (in which case, e and x are both
[75] Fix | Delete
zeroes); otherwise, 0.5 <= abs(x) < 1.0. On overflow, which is
[76] Fix | Delete
possible if the number of bits doesn't fit into a Py_ssize_t, sets
[77] Fix | Delete
OverflowError and returns -1.0 for x, 0 for e. */
[78] Fix | Delete
#ifndef Py_LIMITED_API
[79] Fix | Delete
PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e);
[80] Fix | Delete
#endif
[81] Fix | Delete
[82] Fix | Delete
PyAPI_FUNC(double) PyLong_AsDouble(PyObject *);
[83] Fix | Delete
PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *);
[84] Fix | Delete
PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *);
[85] Fix | Delete
[86] Fix | Delete
PyAPI_FUNC(PyObject *) PyLong_FromLongLong(long long);
[87] Fix | Delete
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned long long);
[88] Fix | Delete
PyAPI_FUNC(long long) PyLong_AsLongLong(PyObject *);
[89] Fix | Delete
PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLong(PyObject *);
[90] Fix | Delete
PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLongMask(PyObject *);
[91] Fix | Delete
PyAPI_FUNC(long long) PyLong_AsLongLongAndOverflow(PyObject *, int *);
[92] Fix | Delete
[93] Fix | Delete
PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
[94] Fix | Delete
#ifndef Py_LIMITED_API
[95] Fix | Delete
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
[96] Fix | Delete
PyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base);
[97] Fix | Delete
PyAPI_FUNC(PyObject *) _PyLong_FromBytes(const char *, Py_ssize_t, int);
[98] Fix | Delete
#endif
[99] Fix | Delete
[100] Fix | Delete
#ifndef Py_LIMITED_API
[101] Fix | Delete
/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
[102] Fix | Delete
v must not be NULL, and must be a normalized long.
[103] Fix | Delete
There are no error cases.
[104] Fix | Delete
*/
[105] Fix | Delete
PyAPI_FUNC(int) _PyLong_Sign(PyObject *v);
[106] Fix | Delete
[107] Fix | Delete
[108] Fix | Delete
/* _PyLong_NumBits. Return the number of bits needed to represent the
[109] Fix | Delete
absolute value of a long. For example, this returns 1 for 1 and -1, 2
[110] Fix | Delete
for 2 and -2, and 2 for 3 and -3. It returns 0 for 0.
[111] Fix | Delete
v must not be NULL, and must be a normalized long.
[112] Fix | Delete
(size_t)-1 is returned and OverflowError set if the true result doesn't
[113] Fix | Delete
fit in a size_t.
[114] Fix | Delete
*/
[115] Fix | Delete
PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v);
[116] Fix | Delete
[117] Fix | Delete
/* _PyLong_DivmodNear. Given integers a and b, compute the nearest
[118] Fix | Delete
integer q to the exact quotient a / b, rounding to the nearest even integer
[119] Fix | Delete
in the case of a tie. Return (q, r), where r = a - q*b. The remainder r
[120] Fix | Delete
will satisfy abs(r) <= abs(b)/2, with equality possible only if q is
[121] Fix | Delete
even.
[122] Fix | Delete
*/
[123] Fix | Delete
PyAPI_FUNC(PyObject *) _PyLong_DivmodNear(PyObject *, PyObject *);
[124] Fix | Delete
[125] Fix | Delete
/* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in
[126] Fix | Delete
base 256, and return a Python int with the same numeric value.
[127] Fix | Delete
If n is 0, the integer is 0. Else:
[128] Fix | Delete
If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB;
[129] Fix | Delete
else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the
[130] Fix | Delete
LSB.
[131] Fix | Delete
If is_signed is 0/false, view the bytes as a non-negative integer.
[132] Fix | Delete
If is_signed is 1/true, view the bytes as a 2's-complement integer,
[133] Fix | Delete
non-negative if bit 0x80 of the MSB is clear, negative if set.
[134] Fix | Delete
Error returns:
[135] Fix | Delete
+ Return NULL with the appropriate exception set if there's not
[136] Fix | Delete
enough memory to create the Python int.
[137] Fix | Delete
*/
[138] Fix | Delete
PyAPI_FUNC(PyObject *) _PyLong_FromByteArray(
[139] Fix | Delete
const unsigned char* bytes, size_t n,
[140] Fix | Delete
int little_endian, int is_signed);
[141] Fix | Delete
[142] Fix | Delete
/* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long
[143] Fix | Delete
v to a base-256 integer, stored in array bytes. Normally return 0,
[144] Fix | Delete
return -1 on error.
[145] Fix | Delete
If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at
[146] Fix | Delete
bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and
[147] Fix | Delete
the LSB at bytes[n-1].
[148] Fix | Delete
If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes
[149] Fix | Delete
are filled and there's nothing special about bit 0x80 of the MSB.
[150] Fix | Delete
If is_signed is 1/true, bytes is filled with the 2's-complement
[151] Fix | Delete
representation of v's value. Bit 0x80 of the MSB is the sign bit.
[152] Fix | Delete
Error returns (-1):
[153] Fix | Delete
+ is_signed is 0 and v < 0. TypeError is set in this case, and bytes
[154] Fix | Delete
isn't altered.
[155] Fix | Delete
+ n isn't big enough to hold the full mathematical value of v. For
[156] Fix | Delete
example, if is_signed is 0 and there are more digits in the v than
[157] Fix | Delete
fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of
[158] Fix | Delete
being large enough to hold a sign bit. OverflowError is set in this
[159] Fix | Delete
case, but bytes holds the least-significant n bytes of the true value.
[160] Fix | Delete
*/
[161] Fix | Delete
PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
[162] Fix | Delete
unsigned char* bytes, size_t n,
[163] Fix | Delete
int little_endian, int is_signed);
[164] Fix | Delete
[165] Fix | Delete
/* _PyLong_FromNbInt: Convert the given object to a PyLongObject
[166] Fix | Delete
using the nb_int slot, if available. Raise TypeError if either the
[167] Fix | Delete
nb_int slot is not available or the result of the call to nb_int
[168] Fix | Delete
returns something not of type int.
[169] Fix | Delete
*/
[170] Fix | Delete
PyAPI_FUNC(PyLongObject *)_PyLong_FromNbInt(PyObject *);
[171] Fix | Delete
[172] Fix | Delete
/* _PyLong_Format: Convert the long to a string object with given base,
[173] Fix | Delete
appending a base prefix of 0[box] if base is 2, 8 or 16. */
[174] Fix | Delete
PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *obj, int base);
[175] Fix | Delete
[176] Fix | Delete
PyAPI_FUNC(int) _PyLong_FormatWriter(
[177] Fix | Delete
_PyUnicodeWriter *writer,
[178] Fix | Delete
PyObject *obj,
[179] Fix | Delete
int base,
[180] Fix | Delete
int alternate);
[181] Fix | Delete
[182] Fix | Delete
PyAPI_FUNC(char*) _PyLong_FormatBytesWriter(
[183] Fix | Delete
_PyBytesWriter *writer,
[184] Fix | Delete
char *str,
[185] Fix | Delete
PyObject *obj,
[186] Fix | Delete
int base,
[187] Fix | Delete
int alternate);
[188] Fix | Delete
[189] Fix | Delete
/* Format the object based on the format_spec, as defined in PEP 3101
[190] Fix | Delete
(Advanced String Formatting). */
[191] Fix | Delete
PyAPI_FUNC(int) _PyLong_FormatAdvancedWriter(
[192] Fix | Delete
_PyUnicodeWriter *writer,
[193] Fix | Delete
PyObject *obj,
[194] Fix | Delete
PyObject *format_spec,
[195] Fix | Delete
Py_ssize_t start,
[196] Fix | Delete
Py_ssize_t end);
[197] Fix | Delete
#endif /* Py_LIMITED_API */
[198] Fix | Delete
[199] Fix | Delete
/* These aren't really part of the int object, but they're handy. The
[200] Fix | Delete
functions are in Python/mystrtoul.c.
[201] Fix | Delete
*/
[202] Fix | Delete
PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int);
[203] Fix | Delete
PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int);
[204] Fix | Delete
[205] Fix | Delete
#ifndef Py_LIMITED_API
[206] Fix | Delete
/* For use by the gcd function in mathmodule.c */
[207] Fix | Delete
PyAPI_FUNC(PyObject *) _PyLong_GCD(PyObject *, PyObject *);
[208] Fix | Delete
#endif /* !Py_LIMITED_API */
[209] Fix | Delete
[210] Fix | Delete
#ifdef Py_BUILD_CORE
[211] Fix | Delete
/*
[212] Fix | Delete
* Default int base conversion size limitation: Denial of Service prevention.
[213] Fix | Delete
*
[214] Fix | Delete
* Chosen such that this isn't wildly slow on modern hardware and so that
[215] Fix | Delete
* everyone's existing deployed numpy test suite passes before
[216] Fix | Delete
* https://github.com/numpy/numpy/issues/22098 is widely available.
[217] Fix | Delete
*
[218] Fix | Delete
* $ python -m timeit -s 's = "1"*4300' 'int(s)'
[219] Fix | Delete
* 2000 loops, best of 5: 125 usec per loop
[220] Fix | Delete
* $ python -m timeit -s 's = "1"*4300; v = int(s)' 'str(v)'
[221] Fix | Delete
* 1000 loops, best of 5: 311 usec per loop
[222] Fix | Delete
* (zen2 cloud VM)
[223] Fix | Delete
*
[224] Fix | Delete
* 4300 decimal digits fits a ~14284 bit number.
[225] Fix | Delete
*/
[226] Fix | Delete
#define _PY_LONG_DEFAULT_MAX_STR_DIGITS 4300
[227] Fix | Delete
/*
[228] Fix | Delete
* Threshold for max digits check. For performance reasons int() and
[229] Fix | Delete
* int.__str__() don't checks values that are smaller than this
[230] Fix | Delete
* threshold. Acts as a guaranteed minimum size limit for bignums that
[231] Fix | Delete
* applications can expect from CPython.
[232] Fix | Delete
*
[233] Fix | Delete
* % python -m timeit -s 's = "1"*640; v = int(s)' 'str(int(s))'
[234] Fix | Delete
* 20000 loops, best of 5: 12 usec per loop
[235] Fix | Delete
*
[236] Fix | Delete
* "640 digits should be enough for anyone." - gps
[237] Fix | Delete
* fits a ~2126 bit decimal number.
[238] Fix | Delete
*/
[239] Fix | Delete
#define _PY_LONG_MAX_STR_DIGITS_THRESHOLD 640
[240] Fix | Delete
[241] Fix | Delete
#if ((_PY_LONG_DEFAULT_MAX_STR_DIGITS != 0) && \
[242] Fix | Delete
(_PY_LONG_DEFAULT_MAX_STR_DIGITS < _PY_LONG_MAX_STR_DIGITS_THRESHOLD))
[243] Fix | Delete
# error "_PY_LONG_DEFAULT_MAX_STR_DIGITS smaller than threshold."
[244] Fix | Delete
#endif
[245] Fix | Delete
[246] Fix | Delete
#endif /* Py_BUILD_CORE */
[247] Fix | Delete
[248] Fix | Delete
#ifdef __cplusplus
[249] Fix | Delete
}
[250] Fix | Delete
#endif
[251] Fix | Delete
#endif /* !Py_LONGOBJECT_H */
[252] Fix | Delete
[253] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function