cpython/Include/cpython
Tim Peters 863729e9c6
bpo-46218: Change long_pow() to sliding window algorithm (GH-30319)
* bpo-46218: Change long_pow() to sliding window algorithm

The primary motivation is to eliminate long_pow's reliance on that the number of bits in a long "digit" is a multiple of 5. Now it no longer cares how many bits are in a digit.

But the sliding window approach also allows cutting the precomputed table of small powers in half, which reduces initialization overhead enough that the approach pays off for smaller exponents too. Depending on exponent bit patterns, a sliding window may also be able to save some bigint multiplies (sometimes when at least 5 consecutive exponent bits are 0, regardless of their starting bit position modulo 5).

Note: boosting the window width to 6 didn't work well overall. It give marginal speed improvements for huge exponents, but the increased overhead (the small-power table needs twice as many entries) made it a loss for smaller exponents.

Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
2022-01-02 13:18:20 -06:00
..
abstract.h bpo-46140: take more Py_buffer arguments as const * (GH-30217) 2021-12-22 15:07:46 +02:00
bytearrayobject.h bpo-35134: Add Include/cpython/bytesobject.h file (GH-18494) 2020-02-12 23:54:31 +01:00
bytesobject.h bpo-42431: Fix outdated bytes comments (GH-23458) 2020-12-03 12:46:16 +02:00
cellobject.h bpo-45476: Add _Py_RVALUE() macro (GH-29860) 2021-11-30 12:14:45 +01:00
ceval.h bpo-45434: Remove Include/eval.h header file (GH-28973) 2021-10-15 13:06:05 +02:00
classobject.h bpo-35134: Move classobject.h to Include/cpython/ (GH-28968) 2021-10-15 09:46:29 +02:00
code.h Remove legacy opcache structs (GH-27164) 2021-07-17 00:49:35 +09:00
compile.h bpo-43244: Add pycore_compile.h header file (GH-25000) 2021-03-24 00:51:50 +01:00
context.h bpo-35134: Move classobject.h to Include/cpython/ (GH-28968) 2021-10-15 09:46:29 +02:00
dictobject.h Fix typos in the Include directory (GH-28745) 2021-10-06 11:32:38 -07:00
fileobject.h bpo-41986: Add Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode back to limited API (GH-22621) 2020-10-10 17:09:45 +03:00
fileutils.h bpo-45582: Port getpath[p].c to Python (GH-29041) 2021-12-03 00:08:42 +00:00
floatobject.h bpo-35134: Add Include/cpython/floatobject.h (GH-28957) 2021-10-14 23:41:06 +02:00
frameobject.h bpo-45786: Allocate space for frame in frame object. (GH-29729) 2021-11-29 12:34:59 +00:00
funcobject.h bpo-44525: Copy free variables in bytecode to allow calls to inner functions to be specialized (GH-29595) 2021-11-23 09:53:24 +00:00
genobject.h bpo-45963: Make space for the InterpreterFrame of a generator in that generator. (GH-29891) 2021-12-06 10:13:49 +00:00
import.h bpo-45696: Deep-freeze selected modules (GH-29118) 2021-11-10 18:01:53 -08:00
initconfig.h bpo-45582: Port getpath[p].c to Python (GH-29041) 2021-12-03 00:08:42 +00:00
listobject.h bpo-45476: Add _Py_RVALUE() macro (GH-29860) 2021-11-30 12:14:45 +01:00
longintrepr.h bpo-46218: Change long_pow() to sliding window algorithm (GH-30319) 2022-01-02 13:18:20 -06:00
longobject.h bpo-35134: Add Include/cpython/longobject.h (GH-29044) 2021-10-19 02:04:52 +02:00
methodobject.h bpo-38787: Add PyCFunction_CheckExact() macro for exact type checks (GH-20024) 2020-05-12 07:12:41 -07:00
object.h bpo-45947: Place dict and values pointer at fixed (negative) offset just before GC header. (GH-29879) 2021-12-07 16:02:53 +00:00
objimpl.h bpo-45947: Place dict and values pointer at fixed (negative) offset just before GC header. (GH-29879) 2021-12-07 16:02:53 +00:00
odictobject.h bpo-35134: Move non-limited C API files to Include/cpython/ (GH-24561) 2021-02-19 15:55:46 +01:00
picklebufobject.h bpo-35134: Move non-limited C API files to Include/cpython/ (GH-24561) 2021-02-19 15:55:46 +01:00
pyctype.h bpo-43816: Add extern "C" to Include/cpython/pyctype.h (GH-25365) 2021-04-13 13:27:21 +02:00
pydebug.h bpo-45434: Convert Py_GETENV() macro to a function (GH-28912) 2021-10-13 03:39:50 +02:00
pyerrors.h bpo-45607: Make it possible to enrich exception displays via setting their __note__ field (GH-29880) 2021-12-03 22:01:15 +00:00
pyfpe.h bpo-35134: Move non-limited C API files to Include/cpython/ (GH-24561) 2021-02-19 15:55:46 +01:00
pylifecycle.h bpo-43795: Remove Py_FrozenMain from the Limited API & Stable ABI (GH-26241) 2021-05-25 04:42:03 -07:00
pymem.h bpo-43795: PEP-652: Clean up the stable ABI/limited API (GH-25482) 2021-04-23 14:17:58 +02:00
pystate.h bpo-45711: Remove type and traceback from exc_info (GH-30122) 2021-12-17 14:46:22 +00:00
pythonrun.h bpo-43868: Remove PyOS_ReadlineFunctionPointer from the stable ABI list (GH-25442) 2021-04-23 14:23:38 +02:00
pytime.h Fix typos in the Include directory (GH-28745) 2021-10-06 11:32:38 -07:00
sysmodule.h bpo-39583: Remove superfluous "extern C" bits from Include/cpython/*.h (GH-18413) 2020-06-01 20:35:56 +02:00
traceback.h bpo-43950: Print columns in tracebacks (PEP 657) (GH-26958) 2021-07-05 00:14:33 +01:00
tupleobject.h bpo-45476: Add _Py_RVALUE() macro (GH-29860) 2021-11-30 12:14:45 +01:00
unicodeobject.h bpo-46007: Exclude PyUnicode_CHECK_INTERNED() from limited C API (GH-29987) 2021-12-09 00:58:09 -08:00
warnings.h bpo-35134: Split warnings.h and weakrefobject.h (GH-29042) 2021-10-19 01:31:57 +02:00
weakrefobject.h bpo-35134: Split warnings.h and weakrefobject.h (GH-29042) 2021-10-19 01:31:57 +02:00