I assumed that this number ( 2^63 - 1
) was the maximum value python could handle, or store as a variable. But these commands seem to be working fine:
>>> sys.maxsize 9223372036854775807 >>> a=sys.maxsize + 1 >>> a 9223372036854775808
So is there any significance at all? Can Python handle arbitrarily large numbers, if computation resoruces permitt?
Note, here's the print-out of my version is:
>>> sys.version 3.5.2 |Anaconda custom (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]'
The sys module in Python provides various functions and variables that are used to manipulate different parts of the Python runtime environment. It allows operating on the interpreter as it provides access to the variables and functions that interact strongly with the interpreter.
Generally, the maximum value representable by an unsigned word will be sys. maxsize * 2 + 1 , and the number of bits in a word will be math. log2(sys. maxsize * 2 + 2) .
These represent numbers in the range -2147483648 through 2147483647.
According to the source code, the maximum size of a list is PY_SSIZE_T_MAX/sizeof(PyObject*) . On a regular 32bit system, this is (4294967295 / 2) / 4 or 536870912. Therefore the maximum size of a python list on a 32 bit system is 536,870,912 elements.
Python can handle arbitrarily large integers in computation. Any integer too big to fit in 64 bits (or whatever the underlying hardware limit is) is handled in software. For that reason, Python 3 doesn't have a sys.maxint
constant.
The value sys.maxsize
, on the other hand, reports the platform's pointer size, and that limits the size of Python's data structures such as strings and lists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With