Skip to content
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

[BigInt tests] ✅ String tests #244

Open
wants to merge 4 commits into
base: biginteger
Choose a base branch
from

Conversation

LiarPrincess
Copy link

Please read the #242 Using tests from “Violet - Python VM written in Swift” before.


All pass.

String parsing

I think that String parsing performance can be improved. 4000 cases with BigInts up to 1280 bits take ~40s on my laptop (2014 rMBP -> mac 11.7 (Big Sur), Xcode 13.2.1, Intel), Violet does this in 1.5s (there is a separate performance PR).

Violet secret:

Instead of using a single BigInt and multiplying it by radix,
we will group scalars into words-sized chunks.
Then we will raise those chunks to appropriate power and add together.

For example:
1_2345_6789 = (1 * 10^8) + (2345 * 10^4) + (6789 * 10^0)

So, we are doing most of our calculations in fast Word,
and then we switch to slow BigInt for a few final operations.

Implemented here. Should I create an issue for this?

@mgriebling
Copy link

Noticed poor performance in the BigInt initializer from a string as well.
See pull request # 261.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants