Skip to content
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

Long list optimization #52

Merged
merged 2 commits into from
Jan 21, 2025
Merged

Long list optimization #52

merged 2 commits into from
Jan 21, 2025

Conversation

aazuspan
Copy link
Owner

@aazuspan aazuspan commented Jan 21, 2025

Related issue

None.

Description

Lists are truncated to "List (n elements)" if the stringified
form is too long, but string conversion is expensive for long lists.
To avoid that, we can calculate the minimum possible string length
and skip stringifying if we exceed it. Based on benchmarking with
the S2 image collection, this is a 10 - 20% speedup for
convert_to_html.

The minimum length formula takes brackets, delimiters, and
whitespace into account, so e.g. the shortest possible 3-element
list is 9 characters: "[1, 1, 1]".

Checklist

  • I have updated the CHANGELOG with any added features, changes, fixes, or removals.

Lists are truncated to "List (n elements)" if the stringified
form is too long, but string conversion is expensive for long lists.
To avoid that, we can calculate the minimum possible string length
and skip stringifying if we exceed it. Based on benchmarking with
the S2 image collection, this is a 10 - 20% speedup for
convert_to_html.

The minimum length formula takes brackets, delimiters, and
whitespace into account, so e.g. the shortest possible 3-element
list is 9 characters: "[1, 1, 1]".
@aazuspan aazuspan added the enhancement New feature or request label Jan 21, 2025
@aazuspan aazuspan self-assigned this Jan 21, 2025
@aazuspan aazuspan merged commit de03fe8 into main Jan 21, 2025
6 checks passed
@aazuspan aazuspan deleted the long-list-optimization branch January 21, 2025 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant