]> granicus.if.org Git - python/commitdiff
Patch #2488: Add sys.maxsize.
authorMartin v. Löwis <martin@v.loewis.de>
Tue, 20 May 2008 08:11:19 +0000 (08:11 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Tue, 20 May 2008 08:11:19 +0000 (08:11 +0000)
Doc/library/sys.rst
Misc/NEWS
Python/sysmodule.c

index 4f6416f1d3804a5ec41d7c675e64a8f17e9cb994..390f73df650f54af9fc6b5bbe041315342446783 100644 (file)
@@ -521,6 +521,11 @@ always available.
    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.
 
+.. data:: 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.
 
 .. data:: maxunicode
 
index befe78d51bdd65bba65188609fe0f8e35cc0e993..e2398ce0ae42cff188d5f6725699dd4a939c5e84 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.6 beta 1?
 Core and Builtins
 -----------------
 
+- Patch #2488: Add sys.maxsize.
+
 - Issue #2353: file.xreadlines() now emits a Py3k warning.
 
 - Issue #2863: generators now have a ``gen.__name__`` attribute that
index c8842503beae44f0b888316b5d8c67b70af755b8..f706a7d42d84e82f559e98a2f23e52b50b7ae5d2 100644 (file)
@@ -992,6 +992,7 @@ PyDoc_STR(
 Static objects:\n\
 \n\
 maxint -- the largest supported integer (the smallest is -maxint-1)\n\
+maxsize -- the largest supported length of containers.\n\
 maxunicode -- the largest supported character\n\
 builtin_module_names -- tuple of module names built into this interpreter\n\
 version -- the version of this interpreter as a string\n\
@@ -1345,6 +1346,8 @@ _PySys_Init(void)
                            PyString_FromString(Py_GetPrefix()));
        SET_SYS_FROM_STRING("exec_prefix",
                            PyString_FromString(Py_GetExecPrefix()));
+       SET_SYS_FROM_STRING("maxsize",
+                           PyInt_FromSsize_t(PY_SSIZE_T_MAX));
        SET_SYS_FROM_STRING("maxint",
                            PyInt_FromLong(PyInt_GetMax()));
        SET_SYS_FROM_STRING("py3kwarning",