diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-09-16 22:10:56 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-09-16 22:10:56 (GMT) |
commit | aa2adc828a0583ee472d42a3b6a8964c822c7ee2 (patch) | |
tree | 48a90588c2477d91722480efaae8325b4c5919c7 /Include | |
parent | 2920adb4df51e7c3c10f9671087037888f010483 (diff) | |
download | cpython-aa2adc828a0583ee472d42a3b6a8964c822c7ee2.zip cpython-aa2adc828a0583ee472d42a3b6a8964c822c7ee2.tar.gz cpython-aa2adc828a0583ee472d42a3b6a8964c822c7ee2.tar.bz2 |
Issue #6713: Improve performance of str(n) and repr(n) for integers n
(up to 3.1 times faster in tests), by special-casing base 10 in
_PyLong_Format. (Backport of r74851 from py3k.)
Diffstat (limited to 'Include')
-rw-r--r-- | Include/longintrepr.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Include/longintrepr.h b/Include/longintrepr.h index d4fcc7e..6425c30 100644 --- a/Include/longintrepr.h +++ b/Include/longintrepr.h @@ -47,12 +47,16 @@ typedef PY_INT32_T sdigit; /* signed variant of digit */ typedef PY_UINT64_T twodigits; typedef PY_INT64_T stwodigits; /* signed variant of twodigits */ #define PyLong_SHIFT 30 +#define _PyLong_DECIMAL_SHIFT 9 /* max(e such that 10**e fits in a digit) */ +#define _PyLong_DECIMAL_BASE ((digit)1000000000) /* 10 ** DECIMAL_SHIFT */ #elif PYLONG_BITS_IN_DIGIT == 15 typedef unsigned short digit; typedef short sdigit; /* signed variant of digit */ typedef unsigned long twodigits; typedef long stwodigits; /* signed variant of twodigits */ #define PyLong_SHIFT 15 +#define _PyLong_DECIMAL_SHIFT 4 /* max(e such that 10**e fits in a digit) */ +#define _PyLong_DECIMAL_BASE ((digit)10000) /* 10 ** DECIMAL_SHIFT */ #else #error "PYLONG_BITS_IN_DIGIT should be 15 or 30" #endif |