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
Simple python program executes more slowly with codon than with python 3.11 #478
Comments
PS:
|
I tried memorizing SUGGEST_CACHE = dict()
def suggest_question(scenarios, n):
# prob: 5.797 5.8025 5.812
# prob + worst: 5.838 5.842
# worst + prob: 5.891
# worst: 6.189
try:
return SUGGEST_CACHE[f"{scenarios} {n}"]
except KeyError:
SUGGEST_CACHE[f"{scenarios} {n}"] = minimal(
zip_fun(
partial(score_prob, scenarios), # probabilistic
# partial(score_worst, scenarios), # worst case
quality1,
quality2,
),
combs(n),
)
return SUGGEST_CACHE[f"{scenarios} {n}"] The change enables the demonstration to complete in 1/6th the time. Edit: Renamed |
Thank you very much, @marioroy, that is an excellent idea. After memoization, the codon version is 31% faster than python. |
@marioroy , I'm generating Fibonacci series with python and the performance results are similar. Python native is 16X faster than codon.
Code :
|
@iamshreeram Compile and run with optimizations with the -release option: |
@iamshreeram Note that Build: |
@elisbyberi , Thanks. That works! |
Hi,
I tested codon on a simple, self-contained python program (code below), which I thought might be type of algorithm to benefit from compilation. To my surprise, the runtime increased. Since it was suggested in the FAQ to open an issue in such instances, here we go.
Best regards,
Peter
The text was updated successfully, but these errors were encountered: