Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
35631537
Commit
35631537
authored
Jan 09, 2009
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce the size of the _PyLong_DigitValue table.
parent
1467ac8e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
4 deletions
+8
-4
Include/longobject.h
Include/longobject.h
+1
-1
Misc/NEWS
Misc/NEWS
+4
-0
Objects/longobject.c
Objects/longobject.c
+3
-3
No files found.
Include/longobject.h
View file @
35631537
...
...
@@ -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.
...
...
Misc/NEWS
View file @
35631537
...
...
@@ -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
...
...
Objects/longobject.c
View file @
35631537
...
...
@@ -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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment