perf: Avoid generating str repr of table during rendering
#1015
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.
What's happening here is that
_repr_mimebundle_creates both the rich HTML content and a plain text repr to show in environments that don't support HTML rendering.So it was taking 11.6 seconds to print the string repr of the Arrow table, just to generate the
_repr_mimebundle_.I'm not clear if this is a regression or just an unhandled bug on the arro3 side (kylebarron/arro3#432). I think arro3 handles long tables by taking the first and last
nrows to print. But it clearly doesn't handle very wide rows at all.Change list
_repr_keysto ensure that the str repr of thetableattribute is never generated. I think this is the only key that should be very slow.Benchmark
99.9% faster rendering 😅
On this branch:
On main:
Closes #1014