10000 bpo-45569: Change PYLONG_BITS_IN_DIGIT default to 30 (GH-30497) · python/cpython@025cbe7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 025cbe7

Browse files
authored
bpo-45569: Change PYLONG_BITS_IN_DIGIT default to 30 (GH-30497)
1 parent ee1a8b3 commit 025cbe7

File tree

6 files changed

+22
-16
lines changed

6 files changed

+22
-16
lines changed

Doc/using/configure.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ General Options
3535

3636
Define the size in bits of Python :class:`int` digits: 15 or 30 bits.
3737

38-
By default, the number of bits is selected depending on ``sizeof(void*)``:
39-
30 bits if ``void*`` size is 64-bit or larger, 15 bits otherwise.
38+
By default, the digit size is 30.
4039

4140
Define the ``PYLONG_BITS_IN_DIGIT`` to ``15`` or ``30``.
4241

Doc/whatsnew/3.11.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,16 @@ Build Changes
622622
like Pyodide.
623623
(Contributed by Christian Heimes and Ethan Smith in :issue:`40280`.)
624624

625+
* CPython will now use 30-bit digits by default for the Python :class:`int`
626+
implementation. Previously, the default was to use 30-bit digits on platforms
627+
with ``SIZEOF_VOID_P >= 8``, and 15-bit digits otherwise. It's still possible
628+
to explicitly request use of 15-bit digits via either the
629+
``--enable-big-digits`` option to the configure script or (for Windows) the
630+
``PYLONG_BITS_IN_DIGIT`` variable in ``PC/pyconfig.h``, but this option may
631+
be removed at some point in the future. (Contributed by Mark Dickinson in
632+
:issue:`45569`.)
633+
634+
625635
C API Changes
626636
=============
627637

Include/pyport.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,12 @@ Used in: Py_SAFE_DOWNCAST
8585
#define PY_INT32_T int32_t
8686
#define PY_INT64_T int64_t
8787

88-
/* If PYLONG_BITS_IN_DIGIT is not defined then we'll use 30-bit digits if all
89-
the necessary integer types are available, and we're on a 64-bit platform
90-
(as determined by SIZEOF_VOID_P); otherwise we use 15-bit digits.
91-
92-
From pyodide: WASM has 32 bit pointers but has native 64 bit arithmetic
93-
so it is more efficient to use 30 bit digits.
88+
/* PYLONG_BITS_IN_DIGIT describes the number of bits per "digit" (limb) in the
89+
* PyLongObject implementation (longintrepr.h). It's currently either 30 or 15,
90+
* defaulting to 30. The 15-bit digit option may be removed in the future.
9491
*/
95-
9692
#ifndef PYLONG_BITS_IN_DIGIT
97-
#if SIZEOF_VOID_P >= 8 || defined(__wasm__)
98-
# define PYLONG_BITS_IN_DIGIT 30
99-
#else
100-
# define PYLONG_BITS_IN_DIGIT 15
101-
#endif
93+
#define PYLONG_BITS_IN_DIGIT 30
10294
#endif
10395

10496
/* uintptr_t is the C9X name for an unsigned integral type such that a
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The build now defaults to using 30-bit digits for Python integers. Previously
2+
either 15-bit or 30-bit digits would be selected, depending on the platform.
3+
15-bit digits may still be selected using the ``--enable-big-digits=15`` option
4+
to the ``configure`` script, or by defining ``PYLONG_BITS_IN_DIGIT`` in
5+
``pyconfig.h``.

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,7 @@ Optional Features:
17301730
Doc/library/socket.rst (default is yes if supported)
17311731
--enable-big-digits[=15|30]
17321732
use big digits (30 or 15 bits) for Python longs
1733-
(default is system-dependent)]
1733+
(default is 30)]
17341734
--disable-test-modules don't build nor install test modules
17351735

17361736
Optional Packages:

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5084,7 +5084,7 @@ AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTL
50845084
# determine what size digit to use for Python's longs
50855085
AC_MSG_CHECKING([digit size for Python's longs])
50865086
AC_ARG_ENABLE(big-digits,
5087-
AS_HELP_STRING([--enable-big-digits@<:@=15|30@:>@],[use big digits (30 or 15 bits) for Python longs (default is system-dependent)]]),
5087+
AS_HELP_STRING([--enable-big-digits@<:@=15|30@:>@],[use big digits (30 or 15 bits) for Python longs (default is 30)]]),
50885088
[case $enable_big_digits in
50895089
yes)
50905090
enable_big_digits=30 ;;

0 commit comments

Comments
 (0)
0