-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Speed up str(int) #6202
Merged
Merged
Speed up str(int) #6202
Conversation
This file contains 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
As title. Fixes numba#6189
Tested speed with: from numba import njit
import time
@njit
def foo(n):
c = 0
for i in range(n):
c += len(str(n))
return c
def test(f):
N = 10
f(1)
ts = time.time()
for i in range(N):
f(1000_000 + i)
te = time.time()
print("Elapsed = %s" % (te - ts))
test(foo.py_func)
test(foo) This implementation seems at least twice as fast as cpython. |
eric-wieser
reviewed
Sep 2, 2020
eric-wieser
reviewed
Sep 2, 2020
As title
esc
approved these changes
Sep 22, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this locally and it does accelerate things quite a bit:
Before
💣 zsh» python issue6202.py
Elapsed = 1.975172758102417
Elapsed = 20.156193017959595
After:
💣 zsh» python issue6202.py
Elapsed = 2.0004079341888428
Elapsed = 0.9646546840667725
@esc is this ready to merge? |
@stuartarchibald it sure is! I have updated the label accordingly. |
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.
As title.
Fixes #6189