7.4.1 Plain Integer Objects

PyIntObject
This subtype of PyObject represents a Python integer object.

PyTypeObject PyInt_Type
This instance of PyTypeObject represents the Python plain integer type.

int PyInt_Check (PyObject *)

PyObject* PyInt_FromLong (long ival)
Creates a new integer object with a value of ival.

The current implementation keeps an array of integer objects for all integers between -1 and 100, 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. :-)

long PyInt_AS_LONG (PyIntObject *io)
Returns the value of the object io. No error checking is performed.

long PyInt_AsLong (PyObject *io)
Will first attempt to cast the object to a PyIntObject, if it is not already one, and then return its value.

long PyInt_GetMax ()
Returns the systems idea of the largest integer it can handle (LONG_MAX, as defined in the system header files).


Send comments on this document to python-docs@python.org.