Skip to content

gh-118750: Asymptotically faster int(string) #118751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 112 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
7ecf234
Adding new, but unsued, `_dec_str_to_int_inner()`, + discussion.
tim-one May 8, 2024
6abc9cc
Correction: `decimal` in this conext computes reciprocals of powers
tim-one May 8, 2024
f4c15ce
Clarify precedence in assert.
tim-one May 8, 2024
8673dcb
Update Lib/_pylong.py
tim-one May 8, 2024
b1aa316
Update Lib/_pylong.py
tim-one May 8, 2024
d9490d0
Update Lib/_pylong.py
tim-one May 8, 2024
734ca08
Merge branch 'main' into str2int
tim-one May 8, 2024
0512f07
Merge branch 'main' into str2int
tim-one May 8, 2024
b2734c2
My memory was wrong: using explicit, cached reciprocal approximations…
tim-one May 8, 2024
c0570e7
Merge branch 'str2int' of https://github.com/tim-one/cpython into str…
tim-one May 8, 2024
9906417
Repair mysterious damage to comment.
tim-one May 8, 2024
27b00ea
Cut the precision of the reciprocal too before multiplying.
tim-one May 8, 2024
46c400b
Merge branch 'main' into str2int
tim-one May 8, 2024
1e1b26d
New comments.
tim-one May 9, 2024
2f3b6b8
Typo repair.
tim-one May 9, 2024
fc2f646
Raise BYTELIM.
tim-one May 9, 2024
0a1daab
For long strings, switch to the new implementation if `_decimal` is p…
tim-one May 9, 2024
1977774
📜🤖 Added by blurb_it.
blurb-it[bot] May 9, 2024
5ce49ae
Update 2024-05-09-02-37-25.gh-issue-118750.7aLfT-.rst
tim-one May 9, 2024
998b871
Do a better job of picking working precision for the multiply.
tim-one May 9, 2024
35605ea
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 9, 2024
53b4fa8
Fotce the initial `w` to be an upper bound on the true value.
tim-one May 9, 2024
34774d6
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 9, 2024
1a78510
Serhiy wore me out ;-) Add best possible log(10, 255) constant.
tim-one May 9, 2024
b766ebf
Repair comment.
tim-one May 9, 2024
3b585fb
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 10, 2024
9cccb8d
Repair test for "close to maybe wrong" initial computation of `w`.
tim-one May 10, 2024
96df6f5
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 10, 2024
a241843
Added exact quotient correction for cases adding 1 once isn't enough.
tim-one May 10, 2024
d67dfd1
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 11, 2024
45708db
Check in testing helper I kept ripping out before earlier commits.
tim-one May 11, 2024
83f07da
And one more test, of thta absurdly large inputs are rejected.
tim-one May 11, 2024
ae41a10
Trying to repair new test that failed on some test platforms.
tim-one May 11, 2024
3779a92
I don't know what the "WASI" testbot is, except that it's annoying ;-)
tim-one May 11, 2024
5140c23
And more random thrashing.
tim-one May 11, 2024
45c1da0
Another random stab at making WASI happy.
tim-one May 11, 2024
ee17e54
More random thrashing to try to shut up WASI :-(
tim-one May 11, 2024
98cfca4
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 11, 2024
ed18fdc
Make GUARD a keyword-only argument. Plus many comment changes.
tim-one May 11, 2024
a5def42
repair spelling mistake in comment
tim-one May 11, 2024
727d396
Update Lib/_pylong.py
tim-one May 11, 2024
505012c
Update Lib/_pylong.py
tim-one May 11, 2024
25b47c7
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 11, 2024
83ea161
I now believe GUARD=3(!) is sufficient. And that's the smallest
tim-one May 11, 2024
07c70bd
Apply suggestions from code review
tim-one May 11, 2024
fcfa5aa
The lint checker whinef about a blank line at the end of the file.
tim-one May 11, 2024
7763ab2
And restoring another code review change.
tim-one May 11, 2024
b1443ef
Update Lib/test/test_int.py
tim-one May 11, 2024
3ee6247
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 12, 2024
44c85ac
Made suggested word change.
tim-one May 12, 2024
1a90eb6
Just commehts: be more careful about explaining how bad the
tim-one May 12, 2024
cd07da3
Typo repair.
tim-one May 12, 2024
a985009
Someone should contribute a spell-checker to IDLE ;-)
tim-one May 12, 2024
7d4c3e8
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 12, 2024
ec326b3
Free the memory for `hi` as soon as we're done with it.
tim-one May 12, 2024
922dca1
Add notes about the details of how reciprocals are computed.
tim-one May 12, 2024
9fe92f3
Repair grammar.
tim-one May 12, 2024
4e360e8
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 12, 2024
4eaccfc
Apply suggestions from code review
tim-one May 12, 2024
19c0690
Merge branch 'str2int' of https://github.com/tim-one/cpython into str…
tim-one May 12, 2024
5178e09
Big change: keeping the exact reciprocals now.
tim-one May 13, 2024
5a0a574
Remove no-longer-useful reset of ctx.prec.
tim-one May 13, 2024
1ee272e
Reciprocal approximations are back - you knew it was coming ;-)
tim-one May 13, 2024
3129d5f
Comment repair.
tim-one May 13, 2024
d1a1fce
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 13, 2024
bfd6247
Finished the proof - no more hand-waving on any point :-)
tim-one May 13, 2024
751aab4
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 13, 2024
81ef287
Fix tiny typos in comments.
tim-one May 13, 2024
d5818df
Fudge. Typo repair is adding new typos too :-(
tim-one May 13, 2024
70e7240
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 13, 2024
ca621e2
Consolidate all the seemingly random observations aboud .adjusted(),
tim-one May 14, 2024
c8b69b8
typo
tim-one May 14, 2024
5cff910
And we don't ever need exact reicrocals after all!
tim-one May 14, 2024
29ecb3f
Remove a mention of exact reciprocals, since they're no longer used.
tim-one May 14, 2024
a2bbe09
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 14, 2024
495fe8e
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 15, 2024
617b5e2
Update comments. No code changes.
tim-one May 15, 2024
28552fb
And exact reciprocals are back.
tim-one May 15, 2024
a523fd4
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 15, 2024
03225f3
Split on ceiling(w/2) instead of on the floor.
tim-one May 15, 2024
0b454ba
Delete a line of unused code.
tim-one May 15, 2024
1afe4df
Update Lib/_pylong.py
tim-one May 15, 2024
6999ec7
Merge branch 'str2int' of https://github.com/tim-one/cpython into str…
tim-one May 15, 2024
1f52d1d
typo
tim-one May 15, 2024
f1469cf
Bah. Another typo.
tim-one May 15, 2024
aa8381a
Merge branch 'main' into str2int
tim-one May 15, 2024
d24ae92
Repair thinko in comment.
tim-one May 15, 2024
e1549b6
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 15, 2024
3d74801
Splitting on ceiling(w/2) gave compute_powers() a harder job.
tim-one May 15, 2024
e435907
Merge branch 'main' into str2int
tim-one May 15, 2024
c6f6126
Reduce excessive indentation.
tim-one May 15, 2024
74bcebb
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 16, 2024
52205b4
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 16, 2024
61253a4
Give compute_powers() another IQ boost.
tim-one May 16, 2024
a2814b5
Add basic compoute_powers() test.
tim-one May 16, 2024
b16e639
At least whan I make a typo, auto-commplete reproduces it ;-)
tim-one May 16, 2024
bc440b8
Fix old typo in comment everyone missed ;-)
tim-one May 16, 2024
60797ab
Correct technical detail in comment.
tim-one May 16, 2024
1d4f3a0
And another stray typo :-(
tim-one May 16, 2024
c5ef2ce
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 16, 2024
0033cd5
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 17, 2024
057b5e9
Apply suggestions from code review
tim-one May 17, 2024
7570147
Merge branch 'str2int' of https://github.com/tim-one/cpython into str…
tim-one May 17, 2024
fc09650
Apply suggestions from code review
tim-one May 17, 2024
484dd0b
Merge branch 'str2int' of https://github.com/tim-one/cpython into str…
tim-one May 17, 2024
6c634c7
Add limit=0 to compute_powers() "by hand" testing.
tim-one May 18, 2024
a288adc
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 18, 2024
9ee61f6
Reduce cutoff for calling the new implementation from 3.5M to 2M.
tim-one May 18, 2024
8d5bc36
Update NEWS.
tim-one May 18, 2024
46cf316
Sheesh - put a wrong number in the new NEWS.
tim-one May 18, 2024
e39985e
Merge remote-tracking branch 'upstream/main' into str2int
tim-one May 18, 2024
f1cf315
Spell out the additional new reason not to do int(Decimal) directly.
tim-one May 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Loading