Skip to main content

Overview

Python integers (int) support arbitrary precision - they can represent integers of any size limited only by available memory.

Type Object

The Python int type.

Type Checking

Check if object is an integer or exactly an integer (not subclass).

Creating Integers

From C Types

Example:

From Strings

Parse integer from string with specified base (2-36, or 0 for auto-detect). Example:

Converting to C Types

Returns: Converted value, or -1 on error (check PyErr_Occurred()) Example:

With Overflow Detection

int*
Set to -1, 0, or 1 indicating underflow, success, or overflow
Example:

Complete Example

See Also