You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Okay, curtsies.formatstring.width_aware_slice() is slow for some reason on long strings. It becomes much faster when you pass the string in smaller chunks.
For example:
print("\x1b[31mhello" * 1000)
won't hang because it gets converted to an FmtStr as 1000 chunks instead of one string
It's the actual solution. At least it takes the part of the code which is responsible for being slow and makes it so fast that it should no longer be the bottleneck.
This has been merged and a new release of Curtsies (0.2.12) has @BenWiederhake's patch. This is a big improvement that will help users now (there are at least 4 issues that are dups of this) so big thanks to @BenWiederhake. The behavior is from the bpython side is still empirically quadratic
so still needs some work.
Since this was introduced by width_aware_slice in ef91741 we might need to revert that. I don't remember the specific cases this was important for, should figure this out.
I've written a linear version of the line splitting behavior that made this still quadratic despite @BenWiederhake fix in curtsies with bpython/curtsies#110 but in the meantime we've stopped using the width-aware solution and released 0.17.1 to fix this behavior.
I'm not totally clear on what width-awareness was solving for us – seems like some edge cases around where to wrap lines that have double-width characters or combining characters in them, but there haven't been any open issues about that. Eventually we can use this for formatting input and correctly position the cursor in the case of double-width and combining characters, but no issues open about that. I'm going to hold off on #731 until the case for why we need it is clearer and we're confident it doesn't cause any regressions.
Activity
sebastinas commentedon Nov 18, 2017
From #717: Regression introduced in ef91741.
sebastinas commentedon Nov 18, 2017
Pinging @ata2001.
ata2001 commentedon Jan 3, 2018
I'm on it.
ata2001 commentedon Jan 3, 2018
Okay,
curtsies.formatstring.width_aware_slice()is slow for some reason on long strings. It becomes much faster when you pass the string in smaller chunks.For example:
won't hang because it gets converted to an FmtStr as 1000 chunks instead of one string
ata2001 commentedon Jan 4, 2018
This is definitely a curtsies issue, I'm going to create a PR optimizing
curtsies.formatstring.width_aware_slice().Fix quadratic runtime of width_aware_slice
BenWiederhake commentedon Jan 6, 2018
I took the freedom of overtaking you.
mock commentedon Jan 18, 2018
is that fix above the solution to the problem or just a workaround?
BenWiederhake commentedon Jan 19, 2018
It's the actual solution. At least it takes the part of the code which is responsible for being slow and makes it so fast that it should no longer be the bottleneck.
thomasballinger commentedon Feb 12, 2018
This has been merged and a new release of Curtsies (0.2.12) has @BenWiederhake's patch. This is a big improvement that will help users now (there are at least 4 issues that are dups of this) so big thanks to @BenWiederhake. The behavior is from the bpython side is still empirically quadratic

so still needs some work.
Since this was introduced by
width_aware_slicein ef91741 we might need to revert that. I don't remember the specific cases this was important for, should figure this out.thomasballinger commentedon Feb 14, 2018
I've written a linear version of the line splitting behavior that made this still quadratic despite @BenWiederhake fix in curtsies with bpython/curtsies#110 but in the meantime we've stopped using the width-aware solution and released 0.17.1 to fix this behavior.
I'm not totally clear on what width-awareness was solving for us – seems like some edge cases around where to wrap lines that have double-width characters or combining characters in them, but there haven't been any open issues about that. Eventually we can use this for formatting input and correctly position the cursor in the case of double-width and combining characters, but no issues open about that. I'm going to hold off on #731 until the case for why we need it is clearer and we're confident it doesn't cause any regressions.