.. highlightlang:: c .. _intobjects: Plain Integer Objects --------------------- .. index:: object: integer .. c:type:: PyIntObject This subtype of :c:type:`PyObject` represents a Python integer object. .. c:var:: PyTypeObject PyInt_Type .. index:: single: IntType (in modules types) This instance of :c:type:`PyTypeObject` represents the Python plain integer type. This is the same object as ``int`` and ``types.IntType``. .. c:function:: int PyInt_Check(PyObject *o) Return true if *o* is of type :c:data:`PyInt_Type` or a subtype of :c:data:`PyInt_Type`. .. versionchanged:: 2.2 Allowed subtypes to be accepted. .. c:function:: int PyInt_CheckExact(PyObject *o) Return true if *o* is of type :c:data:`PyInt_Type`, but not a subtype of :c:data:`PyInt_Type`. .. versionadded:: 2.2 .. c:function:: PyObject* PyInt_FromString(char *str, char **pend, int base) Return a new :c:type:`PyIntObject` or :c:type:`PyLongObject` based on the string value in *str*, which is interpreted according to the radix in *base*. If *pend* is non-*NULL*, ``*pend`` will point to the first character in *str* which follows the representation of the number. If *base* is ``0``, the radix will be determined based on the leading characters of *str*: if *str* starts with ``'0x'`` or ``'0X'``, radix 16 will be used; if *str* starts with ``'0'``, radix 8 will be used; otherwise radix 10 will be used. If *base* is not ``0``, it must be between ``2`` and ``36``, inclusive. Leading spaces are ignored. If there are no digits, :exc:`ValueError` will be raised. If the string represents a number too large to be contained within the machine's :c:type:`long int` type and overflow warnings are being suppressed, a :c:type:`PyLongObject` will be returned. If overflow warnings are not being suppressed, *NULL* will be returned in this case. .. c:function:: PyObject* PyInt_FromLong(long ival) Create a new integer object with a value of *ival*. The current implementation keeps an array of integer objects for all integers between ``-5`` and ``256``, when you create an int in that range you actually just get back a reference to the existing object. So it should be possible to change the value of ``1``. I suspect the behaviour of Python in this case is undefined. :-) .. c:function:: PyObject* PyInt_FromSsize_t(Py_ssize_t ival) Create a new integer object with a value of *ival*. If the value is larger than ``LONG_MAX`` or smaller than ``LONG_MIN``, a long integer object is returned. .. versionadded:: 2.5 .. c:function:: PyObject* PyInt_FromSize_t(size_t ival) Create a new integer object with a value of *ival*. If the value exceeds ``LONG_MAX``, a long integer object is returned. .. versionadded:: 2.5 .. c:function:: long PyInt_AsLong(PyObject *io) Will first attempt to cast the object to a :c:type:`PyIntObject`, if it is not already one, and then return its value. If there is an error, ``-1`` is returned, and the caller should check ``PyErr_Occurred()`` to find out whether there was an error, or whether the value just happened to be -1. .. c:function:: long PyInt_AS_LONG(PyObject *io) Return the value of the object *io*. No error checking is performed. .. c:function:: unsigned long PyInt_AsUnsignedLongMask(PyObject *io) Will first attempt to cast the object to a :c:type:`PyIntObject` or :c:type:`PyLongObject`, if it is not already one, and then return its value as unsigned long. This function does not check for overflow. .. versionadded:: 2.3 .. c:function:: unsigned PY_LONG_LONG PyInt_AsUnsignedLongLongMask(PyObject *io) Will first attempt to cast the object to a :c:type:`PyIntObject` or :c:type:`PyLongObject`, if it is not already one, and then return its value as unsigned long long, without checking for overflow. .. versionadded:: 2.3 .. c:function:: Py_ssize_t PyInt_AsSsize_t(PyObject *io) Will first attempt to cast the object to a :c:type:`PyIntObject` or :c:type:`PyLongObject`, if it is not already one, and then return its value as :c:type:`Py_ssize_t`. .. versionadded:: 2.5 .. c:function:: long PyInt_GetMax() .. index:: single: LONG_MAX Return the system's idea of the largest integer it can handle (:const:`LONG_MAX`, as defined in the system header files). .. c:function:: int PyInt_ClearFreeList() Clear the integer free list. Return the number of items that could not be freed. .. versionadded:: 2.6
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
abstract.txt | File | 702 B | 0644 |
|
allocation.txt | File | 4.63 KB | 0644 |
|
arg.txt | File | 25.33 KB | 0644 |
|
bool.txt | File | 1.27 KB | 0644 |
|
buffer.txt | File | 22.15 KB | 0644 |
|
bytearray.txt | File | 2.13 KB | 0644 |
|
capsule.txt | File | 5.67 KB | 0644 |
|
cell.txt | File | 1.89 KB | 0644 |
|
class.txt | File | 1.81 KB | 0644 |
|
cobject.txt | File | 1.83 KB | 0644 |
|
code.txt | File | 1.59 KB | 0644 |
|
codec.txt | File | 4.5 KB | 0644 |
|
complex.txt | File | 3.98 KB | 0644 |
|
concrete.txt | File | 1.92 KB | 0644 |
|
conversion.txt | File | 6.92 KB | 0644 |
|
datetime.txt | File | 6.26 KB | 0644 |
|
descriptor.txt | File | 1.27 KB | 0644 |
|
dict.txt | File | 7.4 KB | 0644 |
|
exceptions.txt | File | 29.17 KB | 0644 |
|
file.txt | File | 6.02 KB | 0644 |
|
float.txt | File | 3.29 KB | 0644 |
|
function.txt | File | 2.36 KB | 0644 |
|
gcsupport.txt | File | 6.12 KB | 0644 |
|
gen.txt | File | 919 B | 0644 |
|
import.txt | File | 10.95 KB | 0644 |
|
index.txt | File | 578 B | 0644 |
|
init.txt | File | 47.74 KB | 0644 |
|
int.txt | File | 4.47 KB | 0644 |
|
intro.txt | File | 27.8 KB | 0644 |
|
iter.txt | File | 1.21 KB | 0644 |
|
iterator.txt | File | 1.75 KB | 0644 |
|
list.txt | File | 6.21 KB | 0644 |
|
long.txt | File | 8.45 KB | 0644 |
|
mapping.txt | File | 2.81 KB | 0644 |
|
marshal.txt | File | 3.88 KB | 0644 |
|
memory.txt | File | 8.39 KB | 0644 |
|
method.txt | File | 2.05 KB | 0644 |
|
module.txt | File | 3.76 KB | 0644 |
|
none.txt | File | 689 B | 0644 |
|
number.txt | File | 11.64 KB | 0644 |
|
objbuffer.txt | File | 2.46 KB | 0644 |
|
object.txt | File | 16.54 KB | 0644 |
|
objimpl.txt | File | 305 B | 0644 |
|
refcounting.txt | File | 2.87 KB | 0644 |
|
reflection.txt | File | 1.53 KB | 0644 |
|
sequence.txt | File | 8.18 KB | 0644 |
|
set.txt | File | 6.41 KB | 0644 |
|
slice.txt | File | 2.62 KB | 0644 |
|
string.txt | File | 15.05 KB | 0644 |
|
structures.txt | File | 12.09 KB | 0644 |
|
sys.txt | File | 5.58 KB | 0644 |
|
tuple.txt | File | 5.36 KB | 0644 |
|
type.txt | File | 2.48 KB | 0644 |
|
typeobj.txt | File | 61.98 KB | 0644 |
|
unicode.txt | File | 43.95 KB | 0644 |
|
utilities.txt | File | 415 B | 0644 |
|
veryhigh.txt | File | 13.04 KB | 0644 |
|
weakref.txt | File | 2.75 KB | 0644 |
|