-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Accept AbstractChar in count and findall (::Char, ::String) #38675
Conversation
Needs an item in |
Checking for overlap isn't much of an overhead, but thoughts on creating a specialized method for |
I would measure if there's anything to be gained first. The compiler is pretty aggressive with constant propagation, so the specialization might already be happening. Even if it doesn't end up specializing at compile time, LLVM should be able to see that the |
I benchmarked here versions with and without the overlap option, and I could not detect any difference reliably. The fluctuations on the benchmarks, even for long strings (ten sentences or so) are much greater than any possible differences in performance, if there are any. The code_llvm of both seemed to be the same, in the sense that I could not find signs of a conditional in one case that was not present in the other, although I am not much qualified to understand that code. |
That seems definitive enough — no need to special case it. |
Btw, you've got some whitespace issues that need to be fixed. |
I think all is fixed now. Thank you for your help. I hope in the future I will be able to contribute to something more substantial and needing less feedback :-). Nice to learn about how collaborations work at this level. |
No problem at all! It's amazing how much fiddling around goes into seemingly simple changes. You have no idea how many times I've started my day thinking "well, this should be simple" only to have it take up the next several weeks 😬 |
Apparently if this is to be released in 1.6, it needs a |
New feature, doesn't go into 1.6. |
The compat entries we wrote above are of the form
Is that correct? |
No, it should be changed to 1.7. |
I am not sure if @StefanKarpinski wants to comment, as he added the compat entry for the first time. Otherwise I can change that right away. |
The old compat entry was added before 1.6 branched off. We are now on 1.7-dev. |
Also needs a NEWS.md entry. |
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.
updated compat entries
This change solves an issue raised in this post, in which searching for a char in a string results in a Method error: https://discourse.julialang.org/t/method-for-counting-characters-in-string-count-a-batman-vs-count-a-batman/51153
with overlap=true and empty string
Co-authored-by: Stefan Karpinski <[email protected]>
Co-authored-by: Stefan Karpinski <[email protected]>
Co-authored-by: Steven G. Johnson <[email protected]>
…g#38675) This change solves an issue raised in this post, in which searching for a char in a string results in a Method error: https://discourse.julialang.org/t/method-for-counting-characters-in-string-count-a-batman-vs-count-a-batman/51153 Co-authored-by: Stefan Karpinski <[email protected]> Co-authored-by: Steven G. Johnson <[email protected]>
Followup from this thread:
https://discourse.julialang.org/t/method-for-counting-characters-in-string-count-a-batman-vs-count-a-batman/51153
Seems that accepting AbstractChar in this function is enough to solve that problem.