长整数:
没有明确定义的限制。可用地址空间的数量构成了一个实际的限制。
(取自this站点)。查看Numeric Types上的文档,您将在其中看到Long integers have unlimited precision。在Python2中,当整数增长超过其限制时,它们将自动切换到long:>>> import sys
>>> type(sys.maxsize)
>>> type(sys.maxsize+1)
对于整数我们有
maxint和maxsize:
int的最大值可以在Python 2.x中找到,sys.maxint。它在Python 3中被删除,但是sys.maxsize通常可以被使用。来自the changelog:The sys.maxint constant was removed, since there is no longer a limit
to the value of integers. However, sys.maxsize can be used as an
integer larger than any practical list or string index. It conforms to
the implementation’s “natural” integer size and is typically the same
as sys.maxint in previous releases on the same platform (assuming the
same build options).
对the difference(Python 2.x)感兴趣的人:sys.maxint The largest positive integer supported by Python’s regular
integer type. This is at least 2**31-1. The largest negative integer
is -maxint-1 — the asymmetry results from the use of 2’s complement
binary arithmetic.
sys.maxsize The largest positive integer supported by the platform’s
Py_ssize_t type, and thus the maximum size lists, strings, dicts, and
many other containers can have.sys.maxsize
An integer giving the maximum value a variable of type Py_ssize_t can take. It’s usually 2^31 - 1 on a 32-bit platform and
2^63 - 1 on a 64-bit platform.
浮动:
有float("inf")和float("-inf")。这些可以与其他数字类型进行比较:>>> import sys
>>> float("inf") > sys.maxsize
True