更新时间:2023-02-19 23:07:27
Python 支持bignum"整数类型,它可以处理任意大的数字.在 Python 2.5+ 中,这种类型被称为 long
并且与 int
类型分开,但解释器会自动使用更合适的那个.在 Python 3.0+ 中,int
类型已完全删除.
Python supports a "bignum" integer type which can work with arbitrarily large numbers. In Python 2.5+, this type is called long
and is separate from the int
type, but the interpreter will automatically use whichever is more appropriate. In Python 3.0+, the int
type has been dropped completely.
不过,这只是一个实现细节——只要您有 2.5 或更高版本,只需执行标准数学运算,任何超出 32 位数学边界的数字都会自动(并且透明地)转换为 bignum.
That's just an implementation detail, though — as long as you have version 2.5 or better, just perform standard math operations and any number which exceeds the boundaries of 32-bit math will be automatically (and transparently) converted to a bignum.
您可以在 PEP 0237 中找到所有血腥细节.
You can find all the gory details in PEP 0237.