cpython/Objects
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
..
clinic bpo-45155 : Default arguments for int.to_bytes(length=1, byteorder=sys.byteorder) (#28265) 2021-09-15 19:55:24 -07:00
stringlib bpo-35134: Add Include/cpython/floatobject.h (GH-28957) 2021-10-14 23:41:06 +02:00
abstract.c bpo-46140: take more Py_buffer arguments as const * (GH-30217) 2021-12-22 15:07:46 +02:00
accu.c bpo-35081: Move accu.h to Include/internal/pycore_accu.h (GH-10271) 2018-11-01 02:30:36 +01:00
boolobject.c bpo-35134: Move classobject.h to Include/cpython/ (GH-28968) 2021-10-15 09:46:29 +02:00
bytearrayobject.c bpo-45434: Remove pystrhex.h header file (GH-28923) 2021-10-13 15:22:35 +02:00
bytes_methods.c bpo-43179: Generalise alignment for optimised string routines (GH-24624) 2021-03-31 12:12:39 +02:00
bytesobject.c bpo-46008: Make runtime-global object/type lifecycle functions and state consistent. (gh-29998) 2021-12-09 12:59:26 -07:00
call.c 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
capsule.c bpo-45855: document that no_block has no use anymore in PyCapsule_Import (#29665) 2021-12-12 10:49:50 +01:00
cellobject.c bpo-40268: Remove unused pycore_pymem.h includes (GH-19531) 2020-04-15 02:57:50 +02:00
classobject.c bpo-45439: Move _PyObject_VectorcallTstate() to pycore_call.h (GH-28893) 2021-10-14 21:53:04 +02:00
codeobject.c bpo-45954: Rename PyConfig.no_debug_ranges to code_debug_ranges (GH-29886) 2021-12-02 11:43:37 +01:00
complexobject.c bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895) 2021-10-12 08:38:19 +02:00
descrobject.c bpo-45385: Fix reference leak from descr_check (#28719) 2021-10-07 09:51:56 +09:00
dictnotes.txt Issue #15055: update dictnotes.txt. Patch by Mark Shannon. 2012-06-24 21:03:45 +02:00
dictobject.c 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
enumobject.c bpo-43706: Use PEP 590 vectorcall to speed up enumerate() (GH-25154) 2021-10-22 08:20:43 +09:00
exception_handling_notes.txt bpo-44525: Split calls into PRECALL and CALL (GH-30011) 2021-12-14 18:22:44 +00:00
exceptions.c bpo-46107: ExceptionGroup.subgroup()/split() should copy __note__ to the parts (GH-30159) 2021-12-21 10:12:26 +00:00
fileobject.c bpo-45479: Futher simplify Py_UniversalNewlineFgets. (GH-28967) 2021-10-14 23:10:52 -07:00
floatobject.c Revert "bpo-46131: add fastpath for PyFloat_Check() (GH-30200)" (GH-30208) 2021-12-19 15:05:46 -06:00
frameobject.c bpo-46039: Split yield from in two (GH-30035) 2021-12-15 10:30:09 +00:00
funcobject.c 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
genericaliasobject.c bpo-45167: Fix deepcopying of GenericAlias (GH-28324) 2021-09-15 20:25:41 +02:00
genobject.c bpo-45711: Remove type and traceback from exc_info (GH-30122) 2021-12-17 14:46:22 +00:00
interpreteridobject.c bpo-35081: Move interpreteridobject.h to Include/internal/ (GH-28969) 2021-10-15 11:56:34 +02:00
iterobject.c bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895) 2021-10-12 08:38:19 +02:00
listobject.c bpo-46008: Make runtime-global object/type lifecycle functions and state consistent. (gh-29998) 2021-12-09 12:59:26 -07:00
listsort.txt Fix typos in the Objects directory (GH-28766) 2021-10-06 16:57:10 -07:00
lnotab_notes.txt bpo-44525: Split calls into PRECALL and CALL (GH-30011) 2021-12-14 18:22:44 +00:00
longobject.c bpo-46218: Change long_pow() to sliding window algorithm (GH-30319) 2022-01-02 13:18:20 -06:00
memoryobject.c bpo-46140: take more Py_buffer arguments as const * (GH-30217) 2021-12-22 15:07:46 +02:00
methodobject.c bpo-33930: Fix segfault with deep recursion when cleaning method objects (GH-27678) 2021-08-11 00:34:14 +01:00
moduleobject.c bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895) 2021-10-12 08:38:19 +02:00
namespaceobject.c bpo-45482: Rename namespaceobject.h to pycore_namespace.h (GH-28975) 2021-10-15 15:21:21 +02:00
object.c bpo-46008: Make runtime-global object/type lifecycle functions and state consistent. (gh-29998) 2021-12-09 12:59:26 -07:00
obmalloc.c bpo-45526: obmalloc radix use 64 addr bits (GH-29062) 2021-10-21 23:05:46 +02:00
odictobject.c bpo-46085: Fix iterator cache mechanism of OrderedDict. (GH-30290) 2021-12-30 12:35:45 +09:00
picklebufobject.c bpo-36785: PEP 574 implementation (GH-7076) 2019-05-26 17:10:09 +02:00
rangeobject.c bpo-45030: Fix integer overflow in __reduce__ of the range iterator (GH-28000) 2021-09-04 21:02:21 +03:00
README Issue #18093: Factor out the programs that embed the runtime 2014-07-25 21:52:14 +10:00
setobject.c bpo-43413: Revert changes in set.__init__ (GH-28403) 2021-12-26 13:27:01 +02:00
sliceobject.c bpo-43268: Pass interp rather than tstate to internal functions (GH-24580) 2021-02-19 15:10:45 +01:00
structseq.c bpo-46008: Make runtime-global object/type lifecycle functions and state consistent. (gh-29998) 2021-12-09 12:59:26 -07:00
tupleobject.c bpo-46008: Make runtime-global object/type lifecycle functions and state consistent. (gh-29998) 2021-12-09 12:59:26 -07:00
typeobject.c Revert "bpo-46131: add fastpath for PyFloat_Check() (GH-30200)" (GH-30208) 2021-12-19 15:05:46 -06:00
typeslots.inc bpo-41073: PyType_GetSlot() can now accept static types. (GH-21931) 2020-11-10 12:53:46 -08:00
typeslots.py bpo-41073: PyType_GetSlot() can now accept static types. (GH-21931) 2020-11-10 12:53:46 -08:00
unicodectype.c Removed unintentional trailing spaces in non-external and non-generated C files. 2015-03-18 21:53:15 +02:00
unicodeobject.c bpo-46008: Make runtime-global object/type lifecycle functions and state consistent. (gh-29998) 2021-12-09 12:59:26 -07:00
unicodetype_db.h closes bpo-45190: Update Unicode data to version 14.0.0. (GH-28336) 2021-09-14 11:00:38 -07:00
unionobject.c bpo-44662: Add ability to annotate types.Union (#27214) 2021-07-29 21:44:48 +02:00
weakrefobject.c Clean up initialization __class_getitem__ with Py_GenericAlias. (GH-28450) 2021-09-19 18:05:30 +03:00

Source files for various builtin objects