[Python-checkins] r68438 - in python/branches/py3k: Include/longobject.h Misc/NEWS Objects/longobject.c
raymond.hettinger
python-checkins at python.org
Fri Jan 9 04:58:09 CET 2009
Author: raymond.hettinger
Date: Fri Jan 9 04:58:09 2009
New Revision: 68438
Log:
Reduce the size of the _PyLong_DigitValue table.
Modified:
python/branches/py3k/Include/longobject.h
python/branches/py3k/Misc/NEWS
python/branches/py3k/Objects/longobject.c
Modified: python/branches/py3k/Include/longobject.h
==============================================================================
--- python/branches/py3k/Include/longobject.h (original)
+++ python/branches/py3k/Include/longobject.h Fri Jan 9 04:58:09 2009
@@ -41,7 +41,7 @@
#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.
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Fri Jan 9 04:58:09 2009
@@ -12,6 +12,10 @@
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
Modified: python/branches/py3k/Objects/longobject.c
==============================================================================
--- python/branches/py3k/Objects/longobject.c (original)
+++ python/branches/py3k/Objects/longobject.c Fri Jan 9 04:58:09 2009
@@ -1646,7 +1646,7 @@
* 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 @@
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 @@
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);
}
More information about the Python-checkins
mailing list