In the latest Python 2 documentation:
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.
In the latest Python 3 documentation:
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.
The value sys.maxsize
is in this file used on Python 2 with the values specified in the Python 3 documentation:
My question is: what are the possible values sys.maxsize
can take in Python 2? Are these two part of the possible values or not? Are there any other possible values (on other platforms or operating systems, for example)? It would be interesting to find the possible values that it can take in Python 3 too.
Related questions:
sys.maxsize
is telling you something about the C compiler used to compile CPython, so there's no difference between Python 2 and Python 3. It has to do with the C compiler and options that were used, not with the version of Python being compiled.ssize_t
type. Which is a 32-bit or 64-bit signed 2's-complement integer on all platforms I've ever seen ;-) Which correspond exactly to the two specific values you already found.type Py_ssize_t
in the docs because Python had to create its own typedefs (at the C level) for newer C concepts waiting for all the world's C compilers to implement them. Those Python-specific typedefs typically stick around in the source code even after all known C compilers catch up ("not broke, don't fix").