summaryrefslogtreecommitdiff
path: root/Include/longintrepr.h
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-09-16 21:23:34 +0000
committerMark Dickinson <dickinsm@gmail.com>2009-09-16 21:23:34 +0000
commit0a1efd0e4ce407b32854cfb8838ffbcf2a32481c (patch)
tree414fdb03e6f2968fd2bca2d42a0610addc61ebf2 /Include/longintrepr.h
parent3360401980429e71aaf1a6d304451b3771900394 (diff)
downloadcpython-git-0a1efd0e4ce407b32854cfb8838ffbcf2a32481c.tar.gz
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.
Diffstat (limited to 'Include/longintrepr.h')
-rw-r--r--Include/longintrepr.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Include/longintrepr.h b/Include/longintrepr.h
index 7765172be9..3d71a35e73 100644
--- a/Include/longintrepr.h
+++ b/Include/longintrepr.h
@@ -50,12 +50,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