diff options
-rw-r--r-- | Include/longobject.h | 2 | ||||
-rw-r--r-- | Misc/NEWS | 4 | ||||
-rw-r--r-- | Objects/longobject.c | 6 |
3 files changed, 8 insertions, 4 deletions
diff --git a/Include/longobject.h b/Include/longobject.h index 73ca951..7adf9c7 100644 --- a/Include/longobject.h +++ b/Include/longobject.h @@ -41,7 +41,7 @@ PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); #endif /* For use by intobject.c only */ -PyAPI_DATA(int) _PyLong_DigitValue[256]; +PyAPI_DATA(unsigned char) _PyLong_DigitValue[256]; /* _PyLong_AsScaledDouble returns a double x and an exponent e such that the true value is approximately equal to x * 2**(SHIFT*e). e is >= 0. @@ -12,6 +12,10 @@ What's New in Python 3.1 alpha 0 Core and Builtins ----------------- +- The internal table, _PyLong_DigitValue, is now an array of unsigned chars + instead of ints (reducing its size from 4 to 8 times thereby reducing + Python's overall memory). + - Issue #1180193: When importing a module from a .pyc (or .pyo) file with an existing .py counterpart, override the co_filename attributes of all code objects if the original filename is obsolete (which can happen if the diff --git a/Objects/longobject.c b/Objects/longobject.c index 362d0ad..9993d10 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -1646,7 +1646,7 @@ _PyLong_Format(PyObject *aa, int base) * Note that when converting a base B string, a char c is a legitimate * base B digit iff _PyLong_DigitValue[Py_CHARPyLong_MASK(c)] < B. */ -int _PyLong_DigitValue[256] = { +unsigned char _PyLong_DigitValue[256] = { 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, @@ -1710,7 +1710,7 @@ long_from_binary_base(char **str, int base) bits_in_accum = 0; pdigit = z->ob_digit; while (--p >= start) { - int k = _PyLong_DigitValue[Py_CHARMASK(*p)]; + int k = (int)_PyLong_DigitValue[Py_CHARMASK(*p)]; assert(k >= 0 && k < base); accum |= (twodigits)(k << bits_in_accum); bits_in_accum += bits_per_char; @@ -1926,7 +1926,7 @@ digit beyond the first. c = (digit)_PyLong_DigitValue[Py_CHARMASK(*str++)]; for (i = 1; i < convwidth && str != scan; ++i, ++str) { c = (twodigits)(c * base + - _PyLong_DigitValue[Py_CHARMASK(*str)]); + (int)_PyLong_DigitValue[Py_CHARMASK(*str)]); assert(c < PyLong_BASE); } |