-
-
Notifications
You must be signed in to change notification settings - Fork 4
Convert mpz to heap type #195
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
Author
Details# bench.py
from operator import mul
import gmp
import pyperf
runner = pyperf.Runner()
for v in ["1<<7", "1<<38", "1<<300", "1<<3000"]:
i = eval(v)
bn = "(mpz("+v+"))**2"
x = gmp.mpz(i)
runner.bench_func(bn, mul, x, x) |
9f3dbc6 to
871829c
Compare
ab3ed5a to
7214077
Compare
Member
Author
|
Another benchmark:
# bench.py
import pyperf
from gmp import mpz
zero = mpz(0)
one = mpz(1)
two = mpz(2)
three = mpz(3)
# https://en.wikipedia.org/wiki/Collatz_conjecture
def collatz(n):
total = zero
n = mpz(n)
while n > 1:
n = n*three + one if n & one else n//two
total += one
return total
runner = pyperf.Runner()
for i in [97, 871]:
h = f"collatz({i})"
runner.bench_func(h, collatz, i) |
a83d289 to
80b5235
Compare
This was referenced Jan 14, 2026
3c8f4a2 to
e265ce3
Compare
fbc08c5 to
ea00e09
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.