cpython/Lib
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
..
__phello__ bpo-45020: Add more test cases for frozen modules. (gh-28664) 2021-09-30 18:38:52 -06:00
asyncio bpo-23819: Fix asyncio tests on python optimized mode (GH-30195) 2021-12-26 13:13:14 +02:00
collections
concurrent bpo-42413: Replace `concurrent.futures.TimeoutError` and `asyncio.TimeoutError` with builtin `TimeoutError` (GH-30197) 2021-12-19 13:22:40 +02:00
ctypes bpo-45878: convert `try/except` to `self.assertRaises` in `Lib/ctypes/test/test_functions.py` (GH-29721) 2021-11-23 13:12:13 +02:00
curses
dbm
distutils Fix typos in the Lib directory (GH-28775) 2021-10-06 16:13:48 -07:00
email bpo-45239: Fix parsedate_tz when time has more than 2 dots in it (GH-28452) 2021-10-13 18:21:27 +02:00
encodings bpo-45467: Fix IncrementalDecoder and StreamReader in the "raw-unicode-escape" codec (GH-28944) 2021-10-14 20:04:19 +03:00
ensurepip bpo-45343: Update bundled pip to 21.2.4 and setuptools to 58.1.0 (GH-28684) 2021-10-05 23:30:38 +02:00
html bpo-45421: Remove dead code from html.parser (GH-28847) 2021-10-12 10:12:21 -07:00
http bpo-28953: Use `raise from` when raising new IncompleteRead (GH-29861) 2021-12-06 16:10:49 -08:00
idlelib bpo-45495: Add 'case' and 'match' to IDLE completions list. (GH-29000) 2021-10-16 18:44:00 -04:00
importlib bpo-46118: Move importlib.resources to its own package. (#30176) 2021-12-30 21:00:48 -05:00
json bpo-46001: Change OverflowError to RecursionError in JSON library docstrings (GH-29943) 2021-12-07 11:58:40 +02:00
lib2to3 Fix typos in the Lib directory (GH-28775) 2021-10-06 16:13:48 -07:00
logging bpo-46063: Improve algorithm for computing which rolled-over log file… (GH-30093) 2021-12-14 00:53:37 +00:00
msilib [codemod] Fix non-matching bracket pairs (GH-28473) 2021-09-22 01:09:00 +02:00
multiprocessing bpo-25066: Added repr for multiprocessing.Event (GH-29749) 2021-12-09 13:16:45 +00:00
pydoc_data Python 3.11.0a3 2021-12-08 22:24:29 +00:00
site-packages
sqlite3 bpo-45677: Reword first section of `sqlite3` docs (#29326) 2021-11-15 14:22:42 -08:00
test bpo-46218: Change long_pow() to sliding window algorithm (GH-30319) 2022-01-02 13:18:20 -06:00
tkinter bpo-45496: Allow flexibility in winfo_rgb tests (GH-30185) 2021-12-26 13:28:24 +02:00
turtledemo
unittest bpo-22815: Print unexpected successes in summary in TextTestResult (GH-30138) 2021-12-26 13:22:44 +02:00
urllib bpo-45874: Handle empty query string correctly in urllib.parse.parse_qsl (#29716) 2021-12-12 10:41:12 +02:00
venv bpo-45337: Use the realpath of the new executable when creating a venv on Windows (GH-28663) 2021-10-07 21:26:12 +01:00
wsgiref Fix typos in the Lib directory (GH-28775) 2021-10-06 16:13:48 -07:00
xml
xmlrpc bpo-45386: Handle strftime's ValueError graciously in xmlrpc.client (GH-28765) 2021-10-13 18:38:36 +02:00
zoneinfo Fix typos in the Lib directory (GH-28775) 2021-10-06 16:13:48 -07:00
__future__.py
__hello__.py
_aix_support.py
_bootsubprocess.py
_collections_abc.py
_compat_pickle.py
_compression.py
_markupbase.py
_osx_support.py [codemod] Fix non-matching bracket pairs (GH-28473) 2021-09-22 01:09:00 +02:00
_py_abc.py
_pydecimal.py
_pyio.py
_sitebuiltins.py
_strptime.py
_threading_local.py
_weakrefset.py
abc.py
aifc.py
antigravity.py
argparse.py bpo-22047: [argparse] deprecate nested argument groups and mutually exclusive groups (GH-30098) 2021-12-16 15:31:08 +00:00
ast.py bpo-45292: [PEP-654] add except* (GH-29581) 2021-12-14 16:48:15 +00:00
asynchat.py Revert "bpo-28533: Remove asyncore, asynchat, smtpd modules (GH-29521)" (GH-29951) 2021-12-07 12:31:04 +01:00
asyncore.py Revert "bpo-28533: Remove asyncore, asynchat, smtpd modules (GH-29521)" (GH-29951) 2021-12-07 12:31:04 +01:00
base64.py bpo-35970: Add help flag to base64 module (GH-28774) 2021-10-06 18:38:43 -07:00
bdb.py
bisect.py
bz2.py bpo-45475: Revert `__iter__` optimization for GzipFile, BZ2File, and LZMAFile. (GH-29016) 2021-10-19 11:51:48 +09:00
cProfile.py
calendar.py
cgi.py
cgitb.py bpo-10716: Migrating pydoc to html5. (GH-28651) 2021-10-09 09:36:50 +02:00
chunk.py
cmd.py
code.py
codecs.py
codeop.py
colorsys.py
compileall.py Fixed documentation typo in compileall.py (GH-29912) 2021-12-05 00:38:17 +09:00
configparser.py
contextlib.py bpo-25625: add contextlib.chdir (GH-28271) 2021-10-20 00:19:27 +02:00
contextvars.py
copy.py bpo-45752: Remove "array" from list of things that cannot be copied in `copy` module docstring (GH-29555) 2021-11-14 04:56:01 -08:00
copyreg.py
crypt.py
csv.py
dataclasses.py bpo-44674: Use unhashability as a proxy for mutability for default dataclass __init__ arguments. (GH-29867) 2021-12-11 16:12:17 -05:00
datetime.py
decimal.py
difflib.py Fix typos in the Lib directory (GH-28775) 2021-10-06 16:13:48 -07:00
dis.py bpo-45636: Merge all numeric operators (GH-29482) 2021-11-10 22:56:22 -08:00
doctest.py bpo-44904: Fix classmethod property bug in doctest module (GH-28838) 2021-10-28 10:48:02 +03:00
enum.py bpo-45535: Improve output of Enum ``dir()`` (GH-29316) 2021-12-02 08:49:52 -08:00
filecmp.py
fileinput.py
fnmatch.py
fractions.py bpo-44547: Make Fractions objects instances of typing.SupportsInt (GH-27851) 2021-10-22 00:09:47 +02:00
ftplib.py
functools.py bpo-46032: Check types in singledispatch's register() at declaration time (GH-30050) 2021-12-25 14:16:14 +02:00
genericpath.py
getopt.py
getpass.py
gettext.py
glob.py bpo-37578: glob.glob -- added include_hidden parameter (GH-30153) 2021-12-18 06:23:34 -08:00
graphlib.py bpo-45359: Support TopologicalSorter type subscript (GH-28714) 2021-12-08 20:52:57 +02:00
gzip.py bpo-45507: EOFErrors should be thrown for truncated gzip members (GH-29029) 2021-11-19 19:07:05 +01:00
hashlib.py
heapq.py
hmac.py
imaplib.py
imghdr.py
imp.py
inspect.py Remove spaces in empty lines (GH-30121) 2021-12-16 01:35:21 +09:00
io.py
ipaddress.py
keyword.py
linecache.py Fix typos in the Lib directory (GH-28775) 2021-10-06 16:13:48 -07:00
locale.py
lzma.py bpo-45475: Revert `__iter__` optimization for GzipFile, BZ2File, and LZMAFile. (GH-29016) 2021-10-19 11:51:48 +09:00
mailbox.py
mailcap.py
mimetypes.py bpo-42158: Add MIME types for n-triples, n-quads, n3 and trig (GH-23230) 2021-11-20 16:52:00 +01:00
modulefinder.py
netrc.py bpo-28806: Continue work: improve the netrc library (GH-26330) 2021-11-17 11:07:54 +02:00
nntplib.py
ntpath.py bpo-45582: Port getpath[p].c to Python (GH-29041) 2021-12-03 00:08:42 +00:00
nturl2path.py
numbers.py
opcode.py bpo-46072: Add top level stats struct (GH-30169) 2021-12-17 14:48:01 +00:00
operator.py bpo-44019: Add operator.call() to __all__ for the operator module (GH-29110) 2021-10-21 19:05:36 +09:00
optparse.py
os.py
pathlib.py bpo-45853: Fix misspelling and unused import in pathlib (GH-30292) 2021-12-30 09:45:06 +02:00
pdb.py
pickle.py Fix typos in the Lib directory (GH-28775) 2021-10-06 16:13:48 -07:00
pickletools.py
pipes.py
pkgutil.py [codemod] Fix non-matching bracket pairs (GH-28473) 2021-09-22 01:09:00 +02:00
platform.py bpo-40280: Emscripten has no support for subprocesses (GH-29872) 2021-12-02 01:17:37 -08:00
plistlib.py
poplib.py
posixpath.py bpo-45582: Port getpath[p].c to Python (GH-29041) 2021-12-03 00:08:42 +00:00
pprint.py bpo-45557: Fix underscore_numbers in pprint.pprint(). (GH-29129) 2021-10-21 16:42:55 -04:00
profile.py
pstats.py
pty.py
py_compile.py bpo-45428: Fix reading filenames from stdin in py_compile (GH-28848) 2021-10-15 12:38:55 +03:00
pyclbr.py
pydoc.py bpo-40280: Emscripten has no support for subprocesses (GH-29872) 2021-12-02 01:17:37 -08:00
queue.py
quopri.py
random.py Move error test to the function that needs it. Improve error message. (GH-30008) 2021-12-09 20:24:50 -06:00
re.py
reprlib.py bpo-39549: reprlib.Repr uses a “fillvalue” attribute (GH-18343) 2021-09-22 15:45:58 -05:00
rlcompleter.py
runpy.py bpo-45654: No need to freeze types (GH-30028) 2021-12-10 19:09:09 +01:00
sched.py
secrets.py
selectors.py
shelve.py
shlex.py
shutil.py bpo-42174: fallback to sane values if the columns or lines are 0 in get_terminal_size (GH-29046) 2021-10-19 20:42:13 +02:00
signal.py bpo-27718: Fix help for the signal module (GH-30063) 2021-12-13 11:21:55 +02:00
site.py bpo-45582: Port getpath[p].c to Python (GH-29041) 2021-12-03 00:08:42 +00:00
smtpd.py Revert "bpo-28533: Remove asyncore, asynchat, smtpd modules (GH-29521)" (GH-29951) 2021-12-07 12:31:04 +01:00
smtplib.py
sndhdr.py
socket.py
socketserver.py bpo-16594: Add allow_reuse_port on socketserver (GH-30072) 2021-12-13 14:14:17 +02:00
sre_compile.py
sre_constants.py
sre_parse.py
ssl.py
stat.py
statistics.py Fix double-space in exception message (GH-29955) 2021-12-08 12:42:02 +02:00
string.py
stringprep.py
struct.py
subprocess.py
sunau.py
symtable.py
sysconfig.py bpo-45582: Fix test_embed failure during a PGO build on Windows (GH-30014) 2021-12-10 17:13:55 +00:00
tabnanny.py
tarfile.py bpo-39039: tarfile raises descriptive exception from zlib.error (GH-27766) 2021-09-29 11:25:48 +02:00
telnetlib.py
tempfile.py bpo-45192: Fix a bug that infers the type of an os.PathLike[bytes] object as str (GH-28323) 2021-10-20 21:54:41 +02:00
textwrap.py
this.py
threading.py Fix typos in the Lib directory (GH-28775) 2021-10-06 16:13:48 -07:00
timeit.py
token.py
tokenize.py
trace.py
traceback.py bpo-45615: Add missing test for printing traceback for non-exception. Fix traceback.py (GH-30091) 2022-01-02 09:34:03 +00:00
tracemalloc.py
tty.py
turtle.py bpo-45837: Properly deprecate turtle.RawTurtle.settiltangle (GH-29618) 2021-11-18 16:02:48 +01:00
types.py bpo-45664: Fix resolve_bases() and new_class() for GenericAlias instance as a base (GH-29298) 2021-12-05 22:44:01 +02:00
typing.py bpo-45755: [typing] Reveal class attributes of generic in generic aliases in `dir()` (GH-29962) 2021-12-16 22:29:59 +08:00
uu.py
uuid.py
warnings.py
wave.py
weakref.py
webbrowser.py bpo-43424: Deprecate `webbrowser.MacOSXOSAScript._name` attribute (GH-30241) 2021-12-30 10:30:13 +09:00
xdrlib.py
zipapp.py
zipfile.py bpo-39359: [zipfile] add missing "pwd: expected bytes, got str" exception (GH-18031) 2021-09-23 23:37:53 +02:00
zipimport.py