整數物件¶
All integers are implemented as "long" integer objects of arbitrary size.
On error, most PyLong_As* APIs return (return type)-1 which cannot be
distinguished from a number. Use PyErr_Occurred() to disambiguate.
-
type PyLongObject¶
- 為 受限 API 的一部分 (做為一個不透明結構 (opaque struct)).
This subtype of
PyObjectrepresents a Python integer object.
-
PyTypeObject PyLong_Type¶
- 為 穩定 ABI 的一部分.
This instance of
PyTypeObjectrepresents the Python integer type. This is the same object asintin the Python layer.
-
int PyLong_Check(PyObject *p)¶
Return true if its argument is a
PyLongObjector a subtype ofPyLongObject. This function always succeeds.
-
int PyLong_CheckExact(PyObject *p)¶
Return true if its argument is a
PyLongObject, but not a subtype ofPyLongObject. This function always succeeds.
-
PyObject *PyLong_FromLong(long v)¶
- 回傳值:新的參照。 為 穩定 ABI 的一部分.
Return a new
PyLongObjectobject from v, orNULLon failure.CPython 實作細節: CPython keeps an array of integer objects for all integers between
-5and256. When you create an int in that range you actually just get back a reference to the existing object.
-
PyObject *PyLong_FromUnsignedLong(unsigned long v)¶
- 回傳值:新的參照。 為 穩定 ABI 的一部分.
Return a new
PyLongObjectobject from a C unsigned long, orNULLon failure.
-
PyObject *PyLong_FromSsize_t(Py_ssize_t v)¶
- 回傳值:新的參照。 為 穩定 ABI 的一部分.
Return a new
PyLongObjectobject from a CPy_ssize_t, orNULLon failure.
-
PyObject *PyLong_FromSize_t(size_t v)¶
- 回傳值:新的參照。 為 穩定 ABI 的一部分.
Return a new
PyLongObjectobject from a Csize_t, orNULLon failure.
-
PyObject *PyLong_FromLongLong(long long v)¶
- 回傳值:新的參照。 為 穩定 ABI 的一部分.
Return a new
PyLongObjectobject from a C long long, orNULLon failure.
-
PyObject *PyLong_FromInt32(int32_t value)¶
-
PyObject *PyLong_FromInt64(int64_t value)¶
- 為 穩定 ABI 的一部分 自 3.14 版本開始.
Return a new
PyLongObjectobject from a signed C int32_t or int64_t, orNULLwith an exception set on failure.在 3.14 版被加入.
-
PyObject *PyLong_FromUnsignedLongLong(unsigned long long v)¶
- 回傳值:新的參照。 為 穩定 ABI 的一部分.
Return a new
PyLongObjectobject from a C unsigned long long, orNULLon failure.
-
PyObject *PyLong_FromUInt32(uint32_t value)¶
-
PyObject *PyLong_FromUInt64(uint64_t value)¶
- 為 穩定 ABI 的一部分 自 3.14 版本開始.
Return a new
PyLongObjectobject from an unsigned C uint32_t or uint64_t, orNULLwith an exception set on failure.在 3.14 版被加入.
-
PyObject *PyLong_FromDouble(double v)¶
- 回傳值:新的參照。 為 穩定 ABI 的一部分.
Return a new
PyLongObjectobject from the integer part of v, orNULLon failure.
-
PyObject *PyLong_FromString(const char *str, char **pend, int base)¶
- 回傳值:新的參照。 為 穩定 ABI 的一部分.
Return a new
PyLongObjectbased on the string value in str, which is interpreted according to the radix in base, orNULLon failure. If pend is non-NULL, *pend will point to the end of str on success or to the first character that could not be processed on error. If base is0, str is interpreted using the Integer literals definition; in this case, leading zeros in a non-zero decimal number raises aValueError. If