⚡️ Speed up function sql_to_marimo by 18%
#473
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.
📄 18% (0.18x) speedup for
sql_to_marimoinmarimo/_convert/utils.py⏱️ Runtime :
797 microseconds→677 microseconds(best of358runs)📝 Explanation and details
The optimization replaces Python's
textwrap.indent()with a custom implementation that's ~40% faster for theindent_text()function.Key changes:
splitlines(keepends=True)and a generator expression with"".join()instead of the more general-purposetextwrap.indent()Why it's faster:
Test case performance:
The speedup comes primarily from eliminating the textwrap overhead rather than algorithmic improvements, making it effective across all input sizes.
✅ Correctness verification report:
🌀 Generated Regression Tests and Runtime
🔎 Concolic Coverage Tests and Runtime
codeflash_concolic_hg3s6k0k/tmpzi0lkfnp/test_concolic_coverage.py::test_sql_to_marimoTo edit these changes
git checkout codeflash/optimize-sql_to_marimo-mhb61dakand push.