The Python Language Reference, Release 3.4.3
of a container, we imply the values, not the identities of the contained objects; however, when we talk about the
mutability of a container, only the identities of the immediately contained objects are implied. So, if an immutable
container (like a tuple) contains a reference to a mutable object, its value changes if that mutable object is changed.
Types affect almost all aspects of object behavior. Even the importance of object identity is affected in some sense:
for immutable types, operations that compute new values may actually return a reference to any existing object
with the same type and value, while for mutable objects this is not allowed. E.g., after a = 1; b = 1, a and
b may or may not refer to the same object with the value one, depending on the implementation, but after c =
[]; d = [], c and d are guaranteed to refer to two different, unique, newly created empty lists. (Note that c
= d = [] assigns the same object to both c and d.)
3.2 The standard type hierarchy
Below is a list of the types that are built into Python. Extension modules (written in C, Java, or other languages,
depending on the implementation) can define additional types. Future versions of Python may add types to the
type hierarchy (e.g., rational numbers, efficiently stored arrays of integers, etc.), although such additions will often
be provided via the standard library instead.
Some of the type descriptions below contain a paragraph listing ‘special attributes.’ These are attributes that
provide access to the implementation and are not intended for general use. Their definition may change in the
future.
None This type has a single value. There is a single object with this value. This object is accessed through the
built-in name None. It is used to signify the absence of a value in many situations, e.g., it is returned from
functions that don’t explicitly return anything. Its truth value is false.
NotImplemented This type has a single value. There is a single object with this value. This object is accessed
through the built-in name NotImplemented. Numeric methods and rich comparison methods should
return this value if they do not implement the operation for the operands provided. (The interpreter will then
try the reflected operation, or some other fallback, depending on the operator.) Its truth value is true.
See implementing-the-arithmetic-operations for more details.
Ellipsis This type has a single value. There is a single object with this value. This object is accessed through the
literal ... or the built-in name Ellipsis. Its truth value is true.
numbers.Number These are created by numeric literals and returned as results by arithmetic operators and
arithmetic built-in functions. Numeric objects are immutable; once created their value never changes.
Python numbers are of course strongly related to mathematical numbers, but subject to the limitations of
numerical representation in computers.
Python distinguishes between integers, floating point numbers, and complex numbers:
numbers.Integral These represent elements from the mathematical set of integers (positive and neg-
ative).
There are two types of integers:
Integers (int)
These represent numbers in an unlimited range, subject to available (virtual) memory only.
For the purpose of shift and mask operations, a binary representation is assumed, and negative
numbers are represented in a variant of 2’s complement which gives the illusion of an infinite
string of sign bits extending to the left.
Booleans (bool) These represent the truth values False and True. The two objects representing
the values False and True are the only Boolean objects. The Boolean type is a subtype of
the integer type, and Boolean values behave like the values 0 and 1, respectively, in almost all
contexts, the exception being that when converted to a string, the strings "False" or "True"
are returned, respectively.
The rules for integer representation are intended to give the most meaningful interpretation of shift
and mask operations involving negative integers.
16 Chapter 3. Data model