From 4dd019fde36b53b30e69a2ce9cee3f2f9f25c2a6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Tue, 20 May 2008 08:11:19 +0000 Subject: [PATCH] Patch #2488: Add sys.maxsize. --- Doc/library/sys.rst | 5 +++++ Misc/NEWS | 2 ++ Python/sysmodule.c | 3 +++ 3 files changed, 10 insertions(+) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 4f6416f1d3..390f73df65 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -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 diff --git a/Misc/NEWS b/Misc/NEWS index befe78d51b..e2398ce0ae 100644 --- 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 diff --git a/Python/sysmodule.c b/Python/sysmodule.c index c8842503be..f706a7d42d 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -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", -- 2.50.0