Closed rodrigogiraoserrao closed 4 days ago
I also tried optimising Segment.divide
.
Tried two slightly different implementations but the benchmarks showed that I was actually slowing down the function.
I couldn't bring myself to completely throw away the code so I included them in the commit message of commit 7912306.
Attention: Patch coverage is 95.23810%
with 2 lines
in your changes are missing coverage. Please review.
Project coverage is 98.26%. Comparing base (
aabfd16
) to head (85c0419
). Report is 48 commits behind head on master.
Files | Patch % | Lines |
---|---|---|
rich/cells.py | 95.65% | 1 Missing :warning: |
rich/segment.py | 90.00% | 1 Missing :warning: |
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Just discovered that bisect key was added in 3.10.
However, I don't think we will need it. It will work with the tuples--no need to separate them.
It will work with the tuples--no need to separate them.
It works with tuples directly, yes. See 7a53a9f. The performance win becomes less significant, though. Originally the ratio was at 0.57 and now it's at 0.67:
@willmcgugan do you need anything else from me on this PR?
No, its good. Just need to find the time to review.
Going to break this out in to smaller changes.
This PR replaces a couple of searches with the module
bisect
.The screenshot below shows Rich's benchmarks ran, on my machine, on v13.7.1 and on my changes. There were clear wins at the top from the optimisations in
cells.py
.I boxed a region of things that stayed the same but whose underlying code was changed to fix the bug reported in #3299.
I also cut the code in
Text.divide
in half by usingbisect
. TheText.divide
benchmarks show no change but that seems to have a positive impact inText.split
. (8% in this screenshot, 5% - 10% from the multiple times I ran the benchmarks while testing changes).I don't know if I'm supposed to commit and upload the benchmark results, so I didn't for now. I also don't know if “optimised some code” should go on the changelog so I didn't put it there for now.
Fixes #3298 Fixes #3299