7.4.1 Plain Integer Objects
Keywords: api

##
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. This is the same object as `types.IntType`.

int `PyInt_Check` (PyObject* o)
  Return value: Borrowed reference.
  Returns true if o is of type `PyInt_Type`.

PyObject* `PyInt_FromLong` (long ival)
  Return value: New reference.
  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_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_AS_LONG` (PyObject *io)
  Returns the value of the object io. No error checking is performed.

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